Search in sources :

Example 11 with LineCoverageSuiteFitness

use of org.evosuite.coverage.line.LineCoverageSuiteFitness in project evosuite by EvoSuite.

the class ChromosomeTest method testCompositionalGetFitnessForSeveralFunctions.

@Test
public void testCompositionalGetFitnessForSeveralFunctions() {
    Properties.ALGORITHM = Algorithm.MONOTONIC_GA;
    TestSuiteChromosome c = new TestSuiteChromosome();
    LineCoverageSuiteFitness f1 = new LineCoverageSuiteFitness();
    c.addFitness(f1);
    c.setFitness(f1, ANY_DOUBLE_1);
    MethodNoExceptionCoverageSuiteFitness f2 = new MethodNoExceptionCoverageSuiteFitness();
    c.addFitness(f2);
    c.setFitness(f2, ANY_DOUBLE_2);
    OutputCoverageSuiteFitness f3 = new OutputCoverageSuiteFitness();
    c.addFitness(f3);
    c.setFitness(f3, ANY_DOUBLE_3);
    ExceptionCoverageSuiteFitness f4 = new ExceptionCoverageSuiteFitness();
    c.addFitness(f4);
    c.setFitness(f4, ANY_DOUBLE_4);
    double sum = ANY_DOUBLE_1 + ANY_DOUBLE_2 + ANY_DOUBLE_3 + ANY_DOUBLE_4;
    assertEquals(sum, c.getFitness(), 0.001);
}
Also used : OutputCoverageSuiteFitness(org.evosuite.coverage.io.output.OutputCoverageSuiteFitness) LineCoverageSuiteFitness(org.evosuite.coverage.line.LineCoverageSuiteFitness) MethodNoExceptionCoverageSuiteFitness(org.evosuite.coverage.method.MethodNoExceptionCoverageSuiteFitness) ExceptionCoverageSuiteFitness(org.evosuite.coverage.exception.ExceptionCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) MethodNoExceptionCoverageSuiteFitness(org.evosuite.coverage.method.MethodNoExceptionCoverageSuiteFitness) Test(org.junit.Test)

Example 12 with LineCoverageSuiteFitness

use of org.evosuite.coverage.line.LineCoverageSuiteFitness in project evosuite by EvoSuite.

the class SPEA2Test method testDistanceOfEqualChromosomes.

@Test
public void testDistanceOfEqualChromosomes() {
    SPEA2<Chromosome> algorithm = new SPEA2<Chromosome>(null);
    BranchCoverageSuiteFitness branch = new BranchCoverageSuiteFitness();
    LineCoverageSuiteFitness line = new LineCoverageSuiteFitness();
    TestSuiteChromosome t1 = new TestSuiteChromosome();
    t1.setFitness(branch, 0.5);
    t1.setFitness(line, 0.3);
    TestSuiteChromosome t2 = new TestSuiteChromosome();
    t2.setFitness(branch, 0.5);
    t2.setFitness(line, 0.3);
    assertEquals(0.0, algorithm.distanceBetweenObjectives(t1, t2), 0.0);
}
Also used : LineCoverageSuiteFitness(org.evosuite.coverage.line.LineCoverageSuiteFitness) BranchCoverageSuiteFitness(org.evosuite.coverage.branch.BranchCoverageSuiteFitness) Chromosome(org.evosuite.ga.Chromosome) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Aggregations

LineCoverageSuiteFitness (org.evosuite.coverage.line.LineCoverageSuiteFitness)12 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)12 Test (org.junit.Test)12 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)6 Chromosome (org.evosuite.ga.Chromosome)5 ArrayList (java.util.ArrayList)3 IntExampleWithNoElse (com.examples.with.different.packagename.coverage.IntExampleWithNoElse)1 OnlyBranchCoverageSuiteFitness (org.evosuite.coverage.branch.OnlyBranchCoverageSuiteFitness)1 ExceptionCoverageSuiteFitness (org.evosuite.coverage.exception.ExceptionCoverageSuiteFitness)1 OutputCoverageSuiteFitness (org.evosuite.coverage.io.output.OutputCoverageSuiteFitness)1 MethodNoExceptionCoverageSuiteFitness (org.evosuite.coverage.method.MethodNoExceptionCoverageSuiteFitness)1 IntPrimitiveStatement (org.evosuite.testcase.statements.numeric.IntPrimitiveStatement)1