use of org.evosuite.coverage.method.MethodNoExceptionCoverageTestFitness in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testTwoTestsTwoMethodsOneWithException.
@Test
public void testTwoTestsTwoMethodsOneWithException() {
TestCase test1 = new DefaultTestCase();
TestCase test2 = new DefaultTestCase();
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("FooClass", "foo");
test1.addCoveredGoal(goal1);
test2.addCoveredGoal(goal1);
MethodCoverageTestFitness goal2 = new MethodCoverageTestFitness("FooClass", "bar()I");
test1.addCoveredGoal(goal2);
test2.addCoveredGoal(goal2);
ExceptionCoverageTestFitness goal3 = new ExceptionCoverageTestFitness("FooClass", "bar()I", RuntimeException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
test1.addCoveredGoal(goal3);
MethodNoExceptionCoverageTestFitness goal4 = new MethodNoExceptionCoverageTestFitness("FooClass", "bar()I");
test2.addCoveredGoal(goal4);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
String generatedName1 = naming.getName(test1);
String generatedName2 = naming.getName(test2);
assertEquals("testBarThrowsRuntimeException", generatedName1);
assertEquals("testBar", generatedName2);
}
Aggregations