Search in sources :

Example 96 with TestSuiteChromosome

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

the class NumericDynamicSeedingSystemTest method testDynamicSeedingFloat.

// FLOATS
@Test
public void testDynamicSeedingFloat() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = NumericDynamicFloatSeeding.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.CLIENT_ON_THREAD = true;
    Properties.DYNAMIC_SEEDING = true;
    // Properties.ALGORITHM = Properties.Algorithm.ONEPLUSONEEA;
    // Probability of picking value from constants pool
    Properties.DYNAMIC_POOL = 0.8f;
    ConstantPoolManager.getInstance().reset();
    String[] command = new String[] { "-generateSuite", "-class", targetClass, "-Dprint_to_system=true" };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    System.out.println("ConstantPool:\n" + ConstantPoolManager.getInstance().getDynamicConstantPool().toString());
    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 97 with TestSuiteChromosome

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

the class NumericDynamicSeedingSystemTest method testDynamicSeedingLong.

// LONGS
@Test
public void testDynamicSeedingLong() {
    EvoSuite evosuite = new EvoSuite();
    String targetClass = NumericDynamicLongSeeding.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;
    Properties.CLIENT_ON_THREAD = true;
    Properties.DYNAMIC_SEEDING = true;
    // Properties.ALGORITHM = Properties.Algorithm.ONEPLUSONEEA;
    // Probability of picking value from constants pool
    Properties.DYNAMIC_POOL = 0.8;
    ConstantPoolManager.getInstance().reset();
    String[] command = new String[] { "-generateSuite", "-class", targetClass, "-Dprint_to_system=true" };
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    System.out.println("EvolvedTestSuite:\n" + best);
    System.out.println("ConstantPool:\n" + ConstantPoolManager.getInstance().getDynamicConstantPool().toString());
    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 98 with TestSuiteChromosome

use of org.evosuite.testsuite.TestSuiteChromosome 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 99 with TestSuiteChromosome

use of org.evosuite.testsuite.TestSuiteChromosome 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 100 with TestSuiteChromosome

use of org.evosuite.testsuite.TestSuiteChromosome 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)

Aggregations

TestSuiteChromosome (org.evosuite.testsuite.TestSuiteChromosome)536 Test (org.junit.Test)430 EvoSuite (org.evosuite.EvoSuite)392 Properties (org.evosuite.Properties)78 OutputVariable (org.evosuite.statistics.OutputVariable)50 GenericSUTString (com.examples.with.different.packagename.generic.GenericSUTString)49 TestChromosome (org.evosuite.testcase.TestChromosome)47 BranchCoverageSuiteFitness (org.evosuite.coverage.branch.BranchCoverageSuiteFitness)44 TestCase (org.evosuite.testcase.TestCase)43 TestFitnessFunction (org.evosuite.testcase.TestFitnessFunction)30 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)22 Ignore (org.junit.Ignore)19 ArrayList (java.util.ArrayList)17 DefaultLocalSearchObjective (org.evosuite.ga.localsearch.DefaultLocalSearchObjective)17 TestSuiteFitnessFunction (org.evosuite.testsuite.TestSuiteFitnessFunction)14 CheapPurityAnalyzer (org.evosuite.assertion.CheapPurityAnalyzer)13 LineCoverageSuiteFitness (org.evosuite.coverage.line.LineCoverageSuiteFitness)13 InstrumentingClassLoader (org.evosuite.instrumentation.InstrumentingClassLoader)13 ExecutionResult (org.evosuite.testcase.execution.ExecutionResult)10 Method (java.lang.reflect.Method)9