use of org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testCharOutputGoal.
@Test
public void testCharOutputGoal() {
TestCase test = new DefaultTestCase();
OutputCoverageGoal outputGoal1 = new OutputCoverageGoal("FooClass", "foo", Type.CHAR_TYPE, CHAR_ALPHA);
OutputCoverageTestFitness goal1 = new OutputCoverageTestFitness(outputGoal1);
test.addCoveredGoal(goal1);
List<TestCase> tests = new ArrayList<>();
tests.add(test);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooReturningAlphabeticChar", naming.getName(test));
}
use of org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testTwoTestsDifferOnlyInBranches.
@Test
public void testTwoTestsDifferOnlyInBranches() {
Branch b1 = mock(Branch.class);
BytecodeInstruction bi = mock(BytecodeInstruction.class);
when(b1.getInstruction()).thenReturn(bi);
TestCase test1 = new DefaultTestCase();
MethodCoverageTestFitness methodGoal = new MethodCoverageTestFitness("FooClass", "toString");
test1.addCoveredGoal(methodGoal);
BranchCoverageTestFitness branchGoal1 = new BranchCoverageTestFitness(new BranchCoverageGoal(b1, true, "FooClass", "toStringBarFooBlubb", 0));
test1.addCoveredGoal(branchGoal1);
TestCase test2 = new DefaultTestCase();
test2.addCoveredGoal(methodGoal);
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
BranchCoverageTestFitness branchGoal2 = new BranchCoverageTestFitness(new BranchCoverageGoal(b1, false, "FooClass", "toString", 0));
test2.addCoveredGoal(branchGoal2);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testToString0", naming.getName(test1));
assertEquals("testToString1", naming.getName(test2));
}
use of org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testOverloadedMethodWithArray.
@Test
public void testOverloadedMethodWithArray() {
TestCase test1 = new DefaultTestCase();
MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("FooClass", "foo(I)");
test1.addCoveredGoal(goal1);
TestCase test2 = new DefaultTestCase();
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
MethodCoverageTestFitness goal2 = new MethodCoverageTestFitness("FooClass", "foo([I)");
test2.addCoveredGoal(goal2);
TestCase test3 = new DefaultTestCase();
// Need to add statements to change hashCode
test3.addStatement(new IntPrimitiveStatement(test3, 0));
MethodCoverageTestFitness goal3 = new MethodCoverageTestFitness("FooClass", "foo([[I)");
test3.addCoveredGoal(goal3);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
tests.add(test3);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooTakingInt", naming.getName(test1));
assertEquals("testFooTakingIntArray", naming.getName(test2));
assertEquals("testFooTakingIntArrayArray", naming.getName(test3));
}
use of org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testMethodWithExceptions.
@Test
public void testMethodWithExceptions() {
TestCase test1 = new DefaultTestCase();
MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("FooClass", "toString()");
test1.addCoveredGoal(goal1);
TestCase test2 = new DefaultTestCase();
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
MethodCoverageTestFitness goal2 = new MethodCoverageTestFitness("FooClass", "toString2()");
test2.addCoveredGoal(goal2);
ExceptionCoverageTestFitness goal3 = new ExceptionCoverageTestFitness("FooClass", "toString()", MockArithmeticException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
test1.addCoveredGoal(goal3);
test2.addCoveredGoal(goal3);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testToString", naming.getName(test1));
assertEquals("testToString2", naming.getName(test2));
}
use of org.evosuite.junit.naming.methods.CoverageGoalTestNameGenerationStrategy in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testResolveConflict3WithMethodGoals.
@Test
public void testResolveConflict3WithMethodGoals() {
// T1: A, B
// T2: A, C
// T3: B, C
MethodCoverageTestFitness methodGoal1 = new MethodCoverageTestFitness("FooClass", "foo(I)I");
MethodCoverageTestFitness methodGoal2 = new MethodCoverageTestFitness("FooClass", "bar(I)I");
MethodCoverageTestFitness methodGoal3 = new MethodCoverageTestFitness("FooClass", "zoo(I)I");
TestCase test1 = new DefaultTestCase();
test1.addCoveredGoal(methodGoal1);
test1.addCoveredGoal(methodGoal2);
TestCase test2 = new DefaultTestCase();
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
test2.addCoveredGoal(methodGoal1);
test2.addCoveredGoal(methodGoal3);
TestCase test3 = new DefaultTestCase();
// Need to add statements to change hashCode
test3.addStatement(new IntPrimitiveStatement(test3, 1));
test3.addCoveredGoal(methodGoal2);
test3.addCoveredGoal(methodGoal3);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
tests.add(test3);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testBarAndFoo", naming.getName(test1));
assertEquals("testFooAndZoo", naming.getName(test2));
assertEquals("testBarAndZoo", naming.getName(test3));
}
Aggregations