use of org.evosuite.EvoSuite 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);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class HardConstraintsNoDSESystemTest method test.
@Test
public void test() {
Properties.RESET_STATIC_FIELD_GETS = true;
Properties.STOPPING_CONDITION = StoppingCondition.MAXTIME;
Properties.SEARCH_BUDGET = 60;
EvoSuite evosuite = new EvoSuite();
String targetClass = HardConstraints.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Criterion[] { Criterion.BRANCH, Criterion.EXCEPTION };
Properties.MINIMIZE = true;
Properties.ASSERTIONS = true;
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.EvoSuite in project evosuite by EvoSuite.
the class Issta14SystemTest method testLocalSearch.
@Test
public void testLocalSearch() {
// it should be trivial for LS
EvoSuite evosuite = new EvoSuite();
String targetClass = IsstaFoo.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
// force using only LS, no DSE
Properties.DSE_PROBABILITY = 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("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class LO_OtherSystemTest method testBase.
@Test
public void testBase() {
// disable LS/DSE
Properties.LOCAL_SEARCH_RATE = -1;
String targetClass = LO_Other.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Criterion[] { Criterion.BRANCH };
String[] command = new String[] { "-generateSuite", "-class", targetClass };
EvoSuite evosuite = new EvoSuite();
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class LO_OtherSystemTest method testDSE.
@Test
public void testDSE() {
Properties.LOCAL_SEARCH_PROBABILITY = 1.0;
Properties.LOCAL_SEARCH_RATE = 8;
Properties.LOCAL_SEARCH_BUDGET_TYPE = Properties.LocalSearchBudgetType.TESTS;
Properties.LOCAL_SEARCH_BUDGET = 100;
// force DSE, not LS
Properties.DSE_PROBABILITY = 1.0;
Properties.DSE_SOLVER = Properties.SolverType.EVOSUITE_SOLVER;
// no timeout
Properties.CONCOLIC_TIMEOUT = Integer.MAX_VALUE;
String targetClass = LO_Other.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Criterion[] { Criterion.BRANCH };
String[] command = new String[] { "-generateSuite", "-class", targetClass };
EvoSuite evosuite = new EvoSuite();
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
}
Aggregations