use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockJOptionPaneSystemTest method testShowConfirmDialogs3.
@Test
public void testShowConfirmDialogs3() throws Exception {
final String targetClass = AskUserShowConfirmDialogs3.class.getCanonicalName();
Properties.TEST_ARCHIVE = false;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
Properties.TARGET_CLASS = targetClass;
Properties.REPLACE_GUI = true;
Properties.MINIMIZE = true;
// As mutation operators remove instrumentation. This needs fixing first
Properties.ASSERTIONS = false;
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();
Assert.assertNotNull(best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
Assert.assertEquals("Non-optimal fitness: ", 0d, best.getFitness(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class GeneratedFilesEvenWithSandboxSystemTest method testCreateWithNoCatch.
@Test
public void testCreateWithNoCatch() {
Assert.assertFalse(file.exists());
EvoSuite evosuite = new EvoSuite();
String targetClass = OpenStream.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SANDBOX = true;
Properties.JUNIT_TESTS = true;
Properties.VIRTUAL_FS = false;
Properties.JUNIT_CHECK_ON_SEPARATE_PROCESS = false;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
// assuming single fitness function
int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 3, goals);
Assert.assertTrue("Should not achieve optimal coverage ", best.getCoverage() < 1);
// SUT should not generate the file
Assert.assertFalse(file.exists());
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class NumericDynamicSeedingSystemTest method testDynamicSeedingDouble.
// DOUBLES
@Test
public void testDynamicSeedingDouble() {
EvoSuite evosuite = new EvoSuite();
String targetClass = NumericDynamicDoubleSeeding.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CLIENT_ON_THREAD = true;
Properties.DYNAMIC_SEEDING = true;
// Properties.ALGORITHM = Properties.Algorithm.ONEPLUSONEEA;
// Probability of picking value from constants pool
Properties.DYNAMIC_POOL = 0.8d;
ConstantPoolManager.getInstance().reset();
String[] command = new String[] { "-generateSuite", "-class", targetClass, "-Dprint_to_system=true" };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
System.out.println("ConstantPool:\n" + ConstantPoolManager.getInstance().getDynamicConstantPool().toString());
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class NumericDynamicSeedingSystemTest method testDynamicSeedingFloat.
// FLOATS
@Test
public void testDynamicSeedingFloat() {
EvoSuite evosuite = new EvoSuite();
String targetClass = NumericDynamicFloatSeeding.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CLIENT_ON_THREAD = true;
Properties.DYNAMIC_SEEDING = true;
// Properties.ALGORITHM = Properties.Algorithm.ONEPLUSONEEA;
// Probability of picking value from constants pool
Properties.DYNAMIC_POOL = 0.8f;
ConstantPoolManager.getInstance().reset();
String[] command = new String[] { "-generateSuite", "-class", targetClass, "-Dprint_to_system=true" };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
System.out.println("ConstantPool:\n" + ConstantPoolManager.getInstance().getDynamicConstantPool().toString());
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class NumericDynamicSeedingSystemTest method testDynamicSeedingLong.
// LONGS
@Test
public void testDynamicSeedingLong() {
EvoSuite evosuite = new EvoSuite();
String targetClass = NumericDynamicLongSeeding.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CLIENT_ON_THREAD = true;
Properties.DYNAMIC_SEEDING = true;
// Properties.ALGORITHM = Properties.Algorithm.ONEPLUSONEEA;
// Probability of picking value from constants pool
Properties.DYNAMIC_POOL = 0.8;
ConstantPoolManager.getInstance().reset();
String[] command = new String[] { "-generateSuite", "-class", targetClass, "-Dprint_to_system=true" };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
System.out.println("ConstantPool:\n" + ConstantPoolManager.getInstance().getDynamicConstantPool().toString());
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Aggregations