Search in sources :

Example 1 with GoalComparator

use of org.evosuite.junit.naming.methods.GoalComparator in project evosuite by EvoSuite.

the class TestGoalComparator method testCompareEqual.

@Test
public void testCompareEqual() {
    GoalComparator comparator = new GoalComparator();
    ExceptionCoverageTestFitness goal1 = new ExceptionCoverageTestFitness("FooClass", "toString()", MockArithmeticException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
    ExceptionCoverageTestFitness goal2 = new ExceptionCoverageTestFitness("FooClass", "toString()", MockArithmeticException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
    assertEquals(0, comparator.compare(goal1, goal2));
}
Also used : ExceptionCoverageTestFitness(org.evosuite.coverage.exception.ExceptionCoverageTestFitness) GoalComparator(org.evosuite.junit.naming.methods.GoalComparator) Test(org.junit.Test)

Example 2 with GoalComparator

use of org.evosuite.junit.naming.methods.GoalComparator in project evosuite by EvoSuite.

the class TestGoalComparator method testComparatorList.

@Test
public void testComparatorList() {
    GoalComparator comparator = new GoalComparator();
    MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("FooClass", "toString()");
    ExceptionCoverageTestFitness goal2 = new ExceptionCoverageTestFitness("FooClass", "toString()", MockArithmeticException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
    OutputCoverageGoal outputGoal = new OutputCoverageGoal("FooClass", "toString", Type.getType("Ljava.lang.String;"), IOCoverageConstants.REF_NONNULL);
    OutputCoverageTestFitness goal3 = new OutputCoverageTestFitness(outputGoal);
    List<TestFitnessFunction> goals = new ArrayList<>();
    goals.add(goal1);
    goals.add(goal2);
    goals.add(goal3);
    Collections.sort(goals, comparator);
    assertEquals(goal2, goals.get(0));
}
Also used : ExceptionCoverageTestFitness(org.evosuite.coverage.exception.ExceptionCoverageTestFitness) MethodCoverageTestFitness(org.evosuite.coverage.method.MethodCoverageTestFitness) TestFitnessFunction(org.evosuite.testcase.TestFitnessFunction) ArrayList(java.util.ArrayList) OutputCoverageTestFitness(org.evosuite.coverage.io.output.OutputCoverageTestFitness) OutputCoverageGoal(org.evosuite.coverage.io.output.OutputCoverageGoal) GoalComparator(org.evosuite.junit.naming.methods.GoalComparator) Test(org.junit.Test)

Example 3 with GoalComparator

use of org.evosuite.junit.naming.methods.GoalComparator in project evosuite by EvoSuite.

the class TestGoalComparator method testCompareExceptionMethod.

@Test
public void testCompareExceptionMethod() {
    GoalComparator comparator = new GoalComparator();
    MethodCoverageTestFitness goal1 = new MethodCoverageTestFitness("FooClass", "toString()");
    ExceptionCoverageTestFitness goal2 = new ExceptionCoverageTestFitness("FooClass", "toString()", MockArithmeticException.class, ExceptionCoverageTestFitness.ExceptionType.EXPLICIT);
    assertEquals(1, comparator.compare(goal1, goal2));
}
Also used : ExceptionCoverageTestFitness(org.evosuite.coverage.exception.ExceptionCoverageTestFitness) MethodCoverageTestFitness(org.evosuite.coverage.method.MethodCoverageTestFitness) GoalComparator(org.evosuite.junit.naming.methods.GoalComparator) Test(org.junit.Test)

Aggregations

ExceptionCoverageTestFitness (org.evosuite.coverage.exception.ExceptionCoverageTestFitness)3 GoalComparator (org.evosuite.junit.naming.methods.GoalComparator)3 Test (org.junit.Test)3 MethodCoverageTestFitness (org.evosuite.coverage.method.MethodCoverageTestFitness)2 ArrayList (java.util.ArrayList)1 OutputCoverageGoal (org.evosuite.coverage.io.output.OutputCoverageGoal)1 OutputCoverageTestFitness (org.evosuite.coverage.io.output.OutputCoverageTestFitness)1 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)1