use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class SearchStatisticsSystemTest method testGradientBranchesOutputVariable.
@Test
public void testGradientBranchesOutputVariable() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ExampleGradientBranches.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.DYNAMIC_SEEDING = true;
Properties.SEARCH_BUDGET = 2500;
Properties.TRACK_BOOLEAN_BRANCHES = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.Coverage + "," + RuntimeVariable.Gradient_Branches;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
evosuite.parseCommandLine(command);
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable<?> coverage = map.get(RuntimeVariable.Coverage.toString());
Assert.assertNotNull(coverage);
Assert.assertEquals(1.0, coverage.getValue());
OutputVariable<?> gradientBranches = map.get(RuntimeVariable.Gradient_Branches.toString());
Assert.assertNotNull(gradientBranches);
Assert.assertEquals(4, gradientBranches.getValue());
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class SearchStatisticsSystemTest method testHandlingOfNoThreads.
@Test
public void testHandlingOfNoThreads() {
EvoSuite evosuite = new EvoSuite();
String targetClass = NoThreads.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SANDBOX = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.Threads;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
evosuite.parseCommandLine(command);
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable<?> threads = map.get(RuntimeVariable.Threads.toString());
Assert.assertNotNull(threads);
Assert.assertEquals(1, threads.getValue());
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class SearchStatisticsSystemTest method testHandlingOfMultiThreads.
// ignored due to problems of JVM8 crashing on MacOS, and anyway we do not really need to check for threads any more
@Ignore
@Test
public void testHandlingOfMultiThreads() {
EvoSuite evosuite = new EvoSuite();
String targetClass = MultiThreads.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SANDBOX = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.Threads;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
evosuite.parseCommandLine(command);
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable<?> threads = map.get(RuntimeVariable.Threads.toString());
Assert.assertNotNull(threads);
Assert.assertEquals(3, threads.getValue());
// TODO: This test currently fails because MSecurityManager does not set the number
// of threads correctly to avoid a JVM8 crash on MacOS:
// PermissionStatistics.getInstance().countThreads(Thread.currentThread().getThreadGroup().activeCount());
}
use of org.evosuite.EvoSuite in project evosuite by EvoSuite.
the class FactoryTestSystemTest method setupCluster.
@Before
public void setupCluster() {
EvoSuite evosuite = new EvoSuite();
// Archive will remove test calls,
// invalidating testTestCalls
Properties.TEST_ARCHIVE = false;
String targetClass = FactoryExample.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.ASSERTIONS = false;
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 JUnitTestCarvedChromosomeFactorySystemTest method testDifficultClassWithWrongTestFails.
// EvoSuite may also cover it without seeding now.
@Ignore
@Test
public void testDifficultClassWithWrongTestFails() {
EvoSuite evosuite = new EvoSuite();
String targetClass = DifficultClassWithoutCarving.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.TEST_FACTORY = TestFactory.JUNIT;
Properties.SELECTED_JUNIT = DifficultClassTest.class.getCanonicalName();
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.assertTrue("Did not expect optimal coverage: ", best.getCoverage() < 1d);
}
Aggregations