use of org.evosuite.testsuite.TestSuiteChromosome 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.testsuite.TestSuiteChromosome 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.testsuite.TestSuiteChromosome 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.testsuite.TestSuiteChromosome 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);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class LocalSearchNumericSystemTest method runDoubleExample.
private void runDoubleExample(double x, double y) throws ClassNotFoundException, ConstructionFailedException, NoSuchMethodException, SecurityException {
TestCase test = getDoubleTest(x, y);
TestSuiteChromosome suite = new TestSuiteChromosome();
BranchCoverageSuiteFitness fitness = new BranchCoverageSuiteFitness();
BranchCoverageMap.getInstance().searchStarted(null);
assertEquals(4.0, fitness.getFitness(suite), 0.1F);
suite.addTest(test);
assertEquals(1.0, fitness.getFitness(suite), 0.1F);
TestSuiteLocalSearch localSearch = TestSuiteLocalSearch.selectTestSuiteLocalSearch();
LocalSearchObjective<TestSuiteChromosome> localObjective = new DefaultLocalSearchObjective<TestSuiteChromosome>();
localObjective.addFitnessFunction(fitness);
localSearch.doSearch(suite, localObjective);
System.out.println("Fitness: " + fitness.getFitness(suite));
System.out.println("Test suite: " + suite);
assertEquals(0.0, fitness.getFitness(suite), 0.1F);
BranchCoverageMap.getInstance().searchFinished(null);
}
Aggregations