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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations