Search in sources :

Example 86 with EvoSuite

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

the class TrivialForDynamicSeedingSystemTest method testEndsWithWithoutSeeding.

@Test
public void testEndsWithWithoutSeeding() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TrivialForDynamicSeedingEndsWith.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.DYNAMIC_POOL = 0.0;
    ConstantPoolManager.getInstance().reset();
    // , "-Ddynamic_pool=0.0"
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Unexpected coverage: ", 2d / 3d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 87 with EvoSuite

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

the class TrivialForDynamicSeedingSystemTest method testStartsWith.

@Test
public void testStartsWith() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TrivialForDynamicSeedingStartsWith.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    // Properties.DYNAMIC_POOL = 1d / 3d;
    ConstantPoolManager.getInstance().reset();
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 88 with EvoSuite

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

the class TrivialForDynamicSeedingSystemTest method testRegionMatches.

@Test
public void testRegionMatches() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TrivialForDynamicSeedingRegionMatches.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    // Properties.DYNAMIC_POOL = 1d / 3d;
    ConstantPoolManager.getInstance().reset();
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 89 with EvoSuite

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

the class TrivialForDynamicSeedingSystemTest method testRegionMatchesWithoutSeeding.

@Test
public void testRegionMatchesWithoutSeeding() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TrivialForDynamicSeedingRegionMatches.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.DYNAMIC_POOL = 0.0;
    ConstantPoolManager.getInstance().reset();
    // , "-Ddynamic_pool=0.0"
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Unexpected coverage: ", 2d / 3d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Example 90 with EvoSuite

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

the class TrivialForDynamicSeedingSystemTest method testRegionMatchesIgnoreCase.

@Test
public void testRegionMatchesIgnoreCase() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = TrivialForDynamicSeedingRegionMatchesCase.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    // Properties.DYNAMIC_POOL = 1d / 3d;
    ConstantPoolManager.getInstance().reset();
    // , "-Ddynamic_pool=0.333"
    String[] command = new String[] { "-generateSuite", "-class", targetClass };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Also used : EvoSuite(org.evosuite.EvoSuite) TestSuiteChromosome(org.evosuite.testsuite.TestSuiteChromosome) Test(org.junit.Test)

Aggregations

EvoSuite (org.evosuite.EvoSuite)462 Test (org.junit.Test)410 TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)391 Properties (org.evosuite.Properties)86 OutputVariable (org.evosuite.statistics.OutputVariable)61 GenericSUTString (com.examples.with.different.packagename.generic.GenericSUTString)49 SearchStatistics (org.evosuite.statistics.SearchStatistics)16 Ignore (org.junit.Ignore)15 CheapPurityAnalyzer (org.evosuite.assertion.CheapPurityAnalyzer)13 CSVReader (com.opencsv.CSVReader)12 FileReader (java.io.FileReader)12 File (java.io.File)9 TestCase (org.evosuite.testcase.TestCase)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 MethodCoverageFitnessFunctionSystemTest (org.evosuite.coverage.method.MethodCoverageFitnessFunctionSystemTest)7 Before (org.junit.Before)7 TypeSeedingExampleString (com.examples.with.different.packagename.TypeSeedingExampleString)6 TestGenerationResult (org.evosuite.result.TestGenerationResult)6 CalculatorTest (com.examples.with.different.packagename.CalculatorTest)5