use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class MockLocalDateSystemTest method testLocalDate.
@Test
public void testLocalDate() throws Exception {
String targetClass = LocalDateExample.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.JUNIT_TESTS = true;
Properties.JUNIT_CHECK = true;
Properties.REPLACE_CALLS = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
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);
checkUnstable();
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class PreferencesSystemTest method testSystemPreferences.
@Test
public void testSystemPreferences() throws Exception {
String targetClass = PrefsSystem.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
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());
Assert.assertNotNull(best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class PreferencesSystemTest method testNodePreferences.
@Test
public void testNodePreferences() throws Exception {
String targetClass = PrefsNode.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
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());
Assert.assertNotNull(best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class PreferencesSystemTest method testUserPreferences.
@Test
public void testUserPreferences() throws Exception {
String targetClass = PrefsUser.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
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());
Assert.assertNotNull(best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class RandomCallSystemTest method testRandomCall.
@Test
public void testRandomCall() {
EvoSuite evosuite = new EvoSuite();
String targetClass = RandomBranch.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.REPLACE_CALLS = true;
// , "-Dassertions=true"
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: ", 5, goals);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Aggregations