use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class CarverSystemTest method testPublicStaticField.
@Test
public void testPublicStaticField() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Days.class.getCanonicalName();
// Test suite with private static field.
String testClass = TestDaysWithPublicField.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.JUNIT_TESTS = true;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH, Properties.Criterion.METHOD };
String[] command = new String[] { "-class", targetClass, "-Djunit=" + testClass, "-Dselected_junit=" + testClass, "-measureCoverage" };
SearchStatistics result = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(result);
OutputVariable coverage = (OutputVariable) result.getOutputVariables().get("Coverage");
Assert.assertEquals("Non-optimal coverage", 1d, (double) coverage.getValue(), 0.01);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class CarverSystemTest method testPrivateStaticField.
// There doesn't seem to be an easy solution to this so let's ignore it for now
@Ignore
@Test
public void testPrivateStaticField() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Days.class.getCanonicalName();
// Test suite with private static field.
String testClass = TestDays.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.JUNIT_TESTS = true;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH, Properties.Criterion.METHOD };
String[] command = new String[] { "-class", targetClass, "-Djunit=" + testClass, "-Dselected_junit=" + testClass, "-measureCoverage" };
SearchStatistics result = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(result);
OutputVariable coverage = (OutputVariable) result.getOutputVariables().get("Coverage");
Assert.assertEquals("Non-optimal coverage", 1d, (double) coverage.getValue(), 0.01);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class CarverSystemTest method testJodaTestScaledDurationFieldWithException.
// An exception is thrown in the constructor. There is nothing that can be carved...
@Ignore
@Test
public void testJodaTestScaledDurationFieldWithException() {
EvoSuite evosuite = new EvoSuite();
// TestScaledDurationField.test_constructor causes NoSuchMethodException,
// possibly related to a super() call in ScaledDurationField's constructor
String targetClass = ScaledDurationField.class.getCanonicalName();
String testClass = TestScaledDurationFieldWithException.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.JUNIT_TESTS = true;
Properties.PRINT_GOALS = true;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH, Properties.Criterion.METHOD };
Properties.GLOBAL_TIMEOUT = 600;
String[] command = new String[] { "-class", targetClass, "-Djunit=" + testClass, "-Dselected_junit=" + testClass, "-measureCoverage" };
SearchStatistics result = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(result);
OutputVariable coverage = (OutputVariable) result.getOutputVariables().get("MethodCoverage");
Assert.assertEquals("Non-optimal method coverage value", 1d, (double) coverage.getValue(), 0.01);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class StaticSingletonFieldSystemTest method test.
@Test
public void test() {
EvoSuite evosuite = new EvoSuite();
String targetClass = SaticSingletonField.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
Assert.assertNotNull(unstable);
Assert.assertEquals("Unexpected unstabled test cases were generated", Boolean.FALSE, unstable.getValue());
double best_fitness = best.getFitness();
Assert.assertTrue("Optimal coverage was not achieved ", best_fitness == 0.0);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class ResetOrderSystemTest method testResetOrder.
@Test
public void testResetOrder() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ResetOrderClassA.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
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);
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable unstable = map.get(RuntimeVariable.HadUnstableTests.toString());
Assert.assertNotNull(unstable);
Assert.assertEquals(Boolean.FALSE, unstable.getValue());
}
Aggregations