Search in sources :

Example 16 with TestFitnessFactory

use of org.evosuite.coverage.TestFitnessFactory in project evosuite by EvoSuite.

the class MockTcpSystemTest method testReceiveTcp_noBranch.

// TODO put back once we properly handle boolean functions with TT
@Ignore
@Test
public void testReceiveTcp_noBranch() {
    EvoSuite evosuite = new EvoSuite();
    /*
            as there is no branch, covering both boolean outputs with online line coverage
            would not be possible. and so output coverage would be a necessity
         */
    String targetClass = ReceiveTcp_noBranch.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.SEARCH_BUDGET = 20000;
    Properties.VIRTUAL_NET = true;
    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE, Properties.Criterion.OUTPUT };
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    Assert.assertTrue(result != null);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    List<TestFitnessFactory<? extends TestFitnessFunction>> list = TestGenerationStrategy.getFitnessFactories();
    Assert.assertEquals(2, list.size());
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : TestFitnessFunction(org.evosuite.testcase.TestFitnessFunction) EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) TestFitnessFactory(org.evosuite.coverage.TestFitnessFactory) Properties(org.evosuite.Properties) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TestFitnessFactory (org.evosuite.coverage.TestFitnessFactory)16 ArrayList (java.util.ArrayList)10 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)9 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)9 EvoSuite (org.evosuite.EvoSuite)5 MethodReturnsObject (com.examples.with.different.packagename.coverage.MethodReturnsObject)4 Test (org.junit.Test)4 FlagExample1 (com.examples.with.different.packagename.FlagExample1)3 Method (java.lang.reflect.Method)3 BranchCoverageFactory (org.evosuite.coverage.branch.BranchCoverageFactory)3 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)3 DefUseCoverageFactory (org.evosuite.coverage.dataflow.DefUseCoverageFactory)3 DefUseCoverageSuiteFitness (org.evosuite.coverage.dataflow.DefUseCoverageSuiteFitness)3 TestChromosome (org.evosuite.testcase.TestChromosome)3 ConstructorStatement (org.evosuite.testcase.statements.ConstructorStatement)3 IntPrimitiveStatement (org.evosuite.testcase.statements.numeric.IntPrimitiveStatement)3 VariableReference (org.evosuite.testcase.variable.VariableReference)3 GenericClass (org.evosuite.utils.generic.GenericClass)3 GenericConstructor (org.evosuite.utils.generic.GenericConstructor)3 GenericMethod (org.evosuite.utils.generic.GenericMethod)3