@Test
public void testAssertionsIncludeEnums() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ExampleReturningEnum.class.getCanonicalName();
String[] command = new String[] {
"-generateSuite", "-class", targetClass, "-Dassertion_strategy=all" };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome suite = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println(suite.toString());
Assert.assertTrue(suite.size() > 0);
for (TestCase test : suite.getTests()) {
boolean hasEnumAssertion = false;
for(Assertion ass : test.getAssertions()) {
if(ass instanceof PrimitiveAssertion) {
Assert.assertTrue(((PrimitiveAssertion)ass).getValue().getClass().isEnum());
hasEnumAssertion = true;
}
}
Assert.assertTrue("Test has no enum assertions: " + test.toCode(),
hasEnumAssertion);
}
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, suite.getCoverage(), 0.05);
}