Search in sources :

Example 1 with OnlyBranchCoverageSuiteFitness

use of org.evosuite.coverage.branch.OnlyBranchCoverageSuiteFitness in project evosuite by EvoSuite.

the class ChromosomeTest method testCompositionalGetFitnessForTwoFunctions.

@Test
public void testCompositionalGetFitnessForTwoFunctions() {
    Properties.ALGORITHM = Algorithm.MONOTONIC_GA;
    TestSuiteChromosome c = new TestSuiteChromosome();
    LineCoverageSuiteFitness f1 = new LineCoverageSuiteFitness();
    OnlyBranchCoverageSuiteFitness f2 = new OnlyBranchCoverageSuiteFitness();
    c.addFitness(f1);
    c.addFitness(f2);
    c.setFitness(f1, ANY_DOUBLE_1);
    c.setFitness(f2, ANY_DOUBLE_2);
    c.setCoverage(f1, ANY_DOUBLE_BETWEEN_0_AND_1_1);
    c.setCoverage(f2, ANY_DOUBLE_BETWEEN_0_AND_1_2);
    assertEquals(ANY_DOUBLE_1, c.getFitnessInstanceOf(LineCoverageSuiteFitness.class), 0.001);
    assertEquals(ANY_DOUBLE_2, c.getFitnessInstanceOf(OnlyBranchCoverageSuiteFitness.class), 0.001);
    assertEquals(ANY_DOUBLE_BETWEEN_0_AND_1_1, c.getCoverageInstanceOf(LineCoverageSuiteFitness.class), 0.001);
    assertEquals(ANY_DOUBLE_BETWEEN_0_AND_1_2, c.getCoverageInstanceOf(OnlyBranchCoverageSuiteFitness.class), 0.001);
    assertEquals(ANY_DOUBLE_1 + ANY_DOUBLE_2, c.getFitness(), 0.001);
    assertEquals((ANY_DOUBLE_BETWEEN_0_AND_1_1 + ANY_DOUBLE_BETWEEN_0_AND_1_2) / 2, c.getCoverage(), 0.001);
}
Also used : LineCoverageSuiteFitness(org.evosuite.coverage.line.LineCoverageSuiteFitness) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) OnlyBranchCoverageSuiteFitness(org.evosuite.coverage.branch.OnlyBranchCoverageSuiteFitness) Test(org.junit.Test)

Aggregations

OnlyBranchCoverageSuiteFitness (org.evosuite.coverage.branch.OnlyBranchCoverageSuiteFitness)1 LineCoverageSuiteFitness (org.evosuite.coverage.line.LineCoverageSuiteFitness)1 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)1 Test (org.junit.Test)1