use of org.evosuite.EvoSuite 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.EvoSuite 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.EvoSuite 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.EvoSuite 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.EvoSuite in project evosuite by EvoSuite.
the class LambdaInStaticConstructorSystemTest method testNoCrashInCLINIT.
@Test
public void testNoCrashInCLINIT() throws Throwable {
String targetClass = LambdaInStaticConstructor.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.TIMEOUT = 50000000;
Properties.RESET_STATIC_FINAL_FIELDS = true;
EvoSuite evosuite = new EvoSuite();
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println(best.toString());
}
Aggregations