use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ServletSystemTest method testSimpleCase_noJEE.
@Test
public void testSimpleCase_noJEE() {
EvoSuite evosuite = new EvoSuite();
String targetClass = SimpleHttpServlet.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE };
Properties.JEE = false;
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.assertTrue(best.getCoverage() < 1);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class CookieSystemTest method testZ3DSE.
@Test
public void testZ3DSE() {
if (System.getenv("z3_path") == null) {
System.out.println("z3_path should be configured for running this test case");
return;
}
Properties.Z3_PATH = System.getenv("z3_path");
Properties.DSE_SOLVER = SolverType.Z3_SOLVER;
Properties.STOPPING_CONDITION = StoppingCondition.MAXTIME;
Properties.SEARCH_BUDGET = 120;
// should it be trivial for DSE ?
EvoSuite evosuite = new EvoSuite();
String targetClass = Cookie.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Criterion[] { Criterion.LINE, Criterion.BRANCH, Criterion.EXCEPTION, Criterion.WEAKMUTATION, Criterion.OUTPUT, Criterion.METHOD, Criterion.METHODNOEXCEPTION, Criterion.CBRANCH };
Properties.MINIMIZE = false;
Properties.ASSERTIONS = false;
// force using only DSE, no LS
Properties.DSE_PROBABILITY = 1.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);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class DseWithUrlSystemTest method testDSE.
@Test
public void testDSE() {
Properties.DSE_SOLVER = SolverType.EVOSUITE_SOLVER;
Properties.STOPPING_CONDITION = StoppingCondition.MAXTIME;
Properties.SEARCH_BUDGET = 120;
// should it be trivial for DSE ?
EvoSuite evosuite = new EvoSuite();
String targetClass = DseWithURL.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Criterion[] { Criterion.BRANCH, Criterion.EXCEPTION };
Properties.MINIMIZE = true;
Properties.ASSERTIONS = true;
// force using only DSE, no LS
Properties.DSE_PROBABILITY = 1.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);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ExampleHardForGASystemTest method testZ3.
@Test
public void testZ3() {
Assume.assumeTrue(System.getenv("z3_path") != null);
Properties.Z3_PATH = System.getenv("z3_path");
Properties.DSE_SOLVER = SolverType.Z3_SOLVER;
Properties.LOCAL_SEARCH_PROBABILITY = 1.0;
Properties.LOCAL_SEARCH_RATE = 8;
Properties.LOCAL_SEARCH_BUDGET_TYPE = Properties.LocalSearchBudgetType.TESTS;
Properties.LOCAL_SEARCH_BUDGET = 10;
// force using only DSE, no LS
Properties.DSE_PROBABILITY = 1.0;
Properties.CONCOLIC_TIMEOUT = 1000;
EvoSuite evosuite = new EvoSuite();
String targetClass = ExampleHardForGA.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("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ExampleHardForGASystemTest method testBase.
/**
* It is expected that the regular GA will not be able to cover all the
* branches in the given budget, but using a constraint solver will do it
*/
@Test
public void testBase() {
// disable LS
Properties.LOCAL_SEARCH_RATE = -1;
EvoSuite evosuite = new EvoSuite();
String targetClass = ExampleHardForGA.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);
/**
* We expect the coverage will not be 100% branch, since there is at
* least one branch that is particularly hard for GA
*/
Assert.assertTrue(best.getCoverage() < 1d);
}
Aggregations