use of org.evosuite.testcase.DefaultTestCase in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testResolveConflict3.
@Test
public void testResolveConflict3() {
// T1: A, B
// T2: A, C
// T3: B, C
TestCase test1 = new DefaultTestCase();
MethodCoverageTestFitness methodGoal = new MethodCoverageTestFitness("FooClass", "foo(I)I");
test1.addCoveredGoal(methodGoal);
OutputCoverageGoal outputGoalHelper = new OutputCoverageGoal("FooClass", "foo(I)I", Type.INT_TYPE, NUM_ZERO);
OutputCoverageTestFitness outputGoal1 = new OutputCoverageTestFitness(outputGoalHelper);
test1.addCoveredGoal(outputGoal1);
TestCase test2 = new DefaultTestCase();
test2.addCoveredGoal(methodGoal);
// Need to add statements to change hashCode
test2.addStatement(new IntPrimitiveStatement(test2, 0));
InputCoverageGoal inputGoalHelper = new InputCoverageGoal("FooClass", "foo(I)I", 0, Type.INT_TYPE, NUM_POSITIVE);
InputCoverageTestFitness inputGoal1 = new InputCoverageTestFitness(inputGoalHelper);
test2.addCoveredGoal(inputGoal1);
TestCase test3 = new DefaultTestCase();
// test3.addCoveredGoal(methodGoal);
// Need to add statements to change hashCode
test3.addStatement(new IntPrimitiveStatement(test3, 1));
test3.addCoveredGoal(outputGoal1);
test3.addCoveredGoal(inputGoal1);
List<TestCase> tests = new ArrayList<>();
tests.add(test1);
tests.add(test2);
tests.add(test3);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooAndFooReturningZero", naming.getName(test1));
assertEquals("testFooAndFooWithPositive", naming.getName(test2));
// TODO: Is this acceptable? This happens because test 3 has no method goals
assertEquals("testFooReturningZero", naming.getName(test3));
}
use of org.evosuite.testcase.DefaultTestCase in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testBooleanOutputGoal.
@Test
public void testBooleanOutputGoal() {
TestCase test = new DefaultTestCase();
OutputCoverageGoal outputGoal1 = new OutputCoverageGoal("FooClass", "foo", Type.BOOLEAN_TYPE, BOOL_TRUE);
OutputCoverageTestFitness goal1 = new OutputCoverageTestFitness(outputGoal1);
test.addCoveredGoal(goal1);
List<TestCase> tests = new ArrayList<>();
tests.add(test);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooReturningTrue", naming.getName(test));
}
use of org.evosuite.testcase.DefaultTestCase in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testNumericOutputGoal.
@Test
public void testNumericOutputGoal() {
TestCase test = new DefaultTestCase();
OutputCoverageGoal outputGoal1 = new OutputCoverageGoal("FooClass", "foo", Type.INT_TYPE, NUM_POSITIVE);
OutputCoverageTestFitness goal1 = new OutputCoverageTestFitness(outputGoal1);
test.addCoveredGoal(goal1);
List<TestCase> tests = new ArrayList<>();
tests.add(test);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooReturningPositive", naming.getName(test));
}
use of org.evosuite.testcase.DefaultTestCase in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testTwoConstructorsDifferentClasses.
@Test
public void testTwoConstructorsDifferentClasses() {
TestCase test = new DefaultTestCase();
MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("Foo", "<init>()");
test.addCoveredGoal(goal1);
MethodCoverageTestFitness goal2 = new MethodCoverageTestFitness("Bar", "<init>()");
test.addCoveredGoal(goal2);
List<TestCase> tests = new ArrayList<>();
tests.add(test);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
String generatedName = naming.getName(test);
assertEquals("testCreatesBarAndCreatesFoo", generatedName);
}
use of org.evosuite.testcase.DefaultTestCase in project evosuite by EvoSuite.
the class TestCoverageGoalNameGeneration method testEmptyArray.
@Test
public void testEmptyArray() {
TestCase test = new DefaultTestCase();
OutputCoverageGoal outputGoal1 = new OutputCoverageGoal("FooClass", "foo", Type.getType("[Ljava.lang.Object;"), ARRAY_EMPTY);
OutputCoverageTestFitness goal1 = new OutputCoverageTestFitness(outputGoal1);
test.addCoveredGoal(goal1);
List<TestCase> tests = new ArrayList<>();
tests.add(test);
CoverageGoalTestNameGenerationStrategy naming = new CoverageGoalTestNameGenerationStrategy(tests);
assertEquals("testFooReturningEmptyArray", naming.getName(test));
}
Aggregations