@Override
protected void runChild(GeneratedTest testPredicted, RunNotifier notifier) {
notifier.fireTestStarted(describeChild(testPredicted));
try {
//Determine expected test result first:
IResult expectedResult = testPredicted.getExpectedResult();
if (expectedResult == null) {
//Suite was not created with @PredictResult must predict it now
GenerativeTest test = testClass.newInstance();
//Inject a choice generator into the test!
test.choiceGenerator = new SystematicChoiceGenerator(testPredicted.getChoices());
test.generative = true;
try {
test.setup();
expectedResult = test.test();
} catch (ResultException e) {
expectedResult = e;
} finally {
test.teardown();
}
}
//Run the test again and verify
GenerativeTest test = testClass.newInstance();
//Inject a choice generator into the test!
test.choiceGenerator = new SystematicChoiceGenerator(testPredicted.getChoices());
test.generative = false;
try {
test.setup();
Assert.assertEquals(testPredicted.getConfigDescription(), test.getConfigDescription());
IResult actual;
try {
actual = test.test(); //run test in verify mode
} catch (ResultException e) {
actual = e;
}