use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ContainerTransformationSystemTest method testIntegerList.
@Test
public void testIntegerList() {
EvoSuite evosuite = new EvoSuite();
String targetClass = IntegerContainerBranch.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 80000;
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);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 5, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ContainerTransformationSystemTest method testIntegerListList.
@Test
public void testIntegerListList() {
EvoSuite evosuite = new EvoSuite();
String targetClass = IntegerCollectionAllBranch.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 180000;
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);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 5, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class TP1SystemTest method testLocalSearch.
@Test
public void testLocalSearch() {
Properties.MINIMIZATION_TIMEOUT = 10;
Properties.LOCAL_SEARCH_BUDGET = 100;
Properties.LOCAL_SEARCH_BUDGET_TYPE = Properties.LocalSearchBudgetType.TESTS;
EvoSuite evosuite = new EvoSuite();
String targetClass = TP1.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
// force using only LS, no DSE
Properties.DSE_PROBABILITY = 0.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 TP1SystemTest method testZ3.
@Test
public void testZ3() {
Assume.assumeTrue(System.getenv("z3_path") != null);
Properties.Z3_PATH = System.getenv("z3_path");
Properties.LOCAL_SEARCH_BUDGET_TYPE = Properties.LocalSearchBudgetType.TIME;
Properties.LOCAL_SEARCH_BUDGET = 5;
EvoSuite evosuite = new EvoSuite();
String targetClass = TP1.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.DSE_SOLVER = Properties.SolverType.Z3_SOLVER;
// force using only LS, no DSE
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 MockFileSystemTest method testCreateNewTmpFile.
@Test
public void testCreateNewTmpFile() {
EvoSuite evosuite = new EvoSuite();
String targetClass = CreateNewTmpFile.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEARCH_BUDGET = 20000;
Properties.VIRTUAL_FS = true;
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);
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Aggregations