use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class RegexSystemTest method testDSE.
@Test
public void testDSE() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Regex.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.PRINT_TO_SYSTEM = true;
// force using only DSE, no LS
Properties.DSE_PROBABILITY = 1.0;
Properties.CRITERION = new Criterion[] { // these are basic criteria that should be always on by default
Criterion.LINE, Criterion.BRANCH, Criterion.EXCEPTION, Criterion.WEAKMUTATION, Criterion.OUTPUT, Criterion.METHOD, Criterion.METHODNOEXCEPTION, Criterion.CBRANCH };
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);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class BreederGASystemTest method testLambdaGAIntegration.
@Test
public void testLambdaGAIntegration() {
Properties.ALGORITHM = Properties.Algorithm.BREEDER_GA;
Properties.TRUNCATION_RATE = 0.1;
EvoSuite evoSuite = new EvoSuite();
String targetClass = BMICalculator.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evoSuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
Assert.assertEquals(BreederGA.class, ga.getClass());
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertEquals(0.0, best.getFitness(), 0.0);
Assert.assertEquals(1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class MIOSystemTest method test.
private void test(double exploitation_starts_at_percent) {
Properties.ALGORITHM = Properties.Algorithm.MIO;
Properties.ARCHIVE_TYPE = Properties.ArchiveType.MIO;
Properties.NUMBER_OF_TESTS_PER_TARGET = 3;
Properties.EXPLOITATION_STARTS_AT_PERCENT = exploitation_starts_at_percent;
String targetClass = BMICalculator.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
EvoSuite evoSuite = new EvoSuite();
GeneticAlgorithm<?> ga = getGAFromResult(evoSuite.parseCommandLine(command));
Assert.assertEquals(MIO.class, ga.getClass());
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertEquals(0.0, best.getFitness(), 0.0);
Assert.assertEquals(1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class OnePlusOneEASystemTest method systemtTestLambdaEA.
@Test
public void systemtTestLambdaEA() {
Properties.ALGORITHM = Algorithm.ONE_PLUS_ONE_EA;
EvoSuite evoSuite = new EvoSuite();
String targetClass = BMICalculator.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
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(0.0, best.getFitness(), 0.0);
Assert.assertEquals(1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class StandardChemicalReactionSystemTest method testIntegration.
@Test
public void testIntegration() {
GeneticAlgorithm<?> ga = test(0.2, 500, 10);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
// the integration test must covers all goals as it uses all functionalities
Assert.assertEquals(0.0, best.getFitness(), 0.0);
Assert.assertEquals(1d, best.getCoverage(), 0.001);
}
Aggregations