TestCases or SequentialTestCases in particular allow to verify that derived solutions states and abstract questions match the expectations defined the respective TestCase.
This article describes how to create and a SequentialTestCase in your Java workspace. If you want to know how to use and define a TestCase in KnowWE, you can learn more on the following wiki article: Doc TestCase
To create a SequentialTestCase you need the information you want to set and check and you also need the knowledge base for which the SequentialTestCase should be used.
Loading a knowledge base from a .d3web-file is pretty simple and can be done with the code snipplets presented on the page How-To Load a Knowledge Base.
To instantiate a SequentialTestCase just use the default constructor:
SequentialTestCase stc = new SequentialTestCase();
A SequentialTestCases can contain multiple RatedTestCases. These RatedTestCases contain the actual inputs and checks for the knowledge base and are sequentially applied to the testing session. For each RatedTestCase it is also possible to set a timestamp for which the RatedTestCase will then be applied to the session.
After instantiating the RatedTestCase, you can add three types of elements:
Example code:
RatedTestCase rtc = new RatedTestCase(); rtc.setTimeStamp(date); rtc.addFinding(new Finding(question, value)); rtc.addExpectedFinding(new Finding(question, value)); rtc.addDerived(new RatedSolution(solution, rating));
The variables question and solution are the well known objects that can be retrieved from your knowledge base (knowledgeBase.getManager().search(name)). As the value a Finding expects a object of the type QuestionValue. In most cases this will be a ChoiceValue or a NumValue which can be instantiated with a simple String or double.