use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class StaticSingletonResetSystemTest method testResetWithAssertionGenerationAll.
@Test
public void testResetWithAssertionGenerationAll() {
Properties.RESET_STATIC_FIELD_GETS = true;
Properties.RESET_STATIC_FIELDS = true;
Properties.JUNIT_CHECK = true;
Properties.JUNIT_TESTS = true;
Properties.SANDBOX = true;
Properties.ASSERTION_STRATEGY = Properties.AssertionStrategy.ALL;
EvoSuite evosuite = new EvoSuite();
String targetClass = SingletonObjectReset.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
// Otherwise the private constructor is counted as coverage target
// but can only be covered by reflection
Properties.P_REFLECTION_ON_PRIVATE = 0.0;
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);
double best_fitness = best.getFitness();
Assert.assertTrue("Optimal coverage was not achieved ", best_fitness == 0.0);
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());
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class StringUserSystemTest method testStringUser.
@Test
public void testStringUser() {
EvoSuite evosuite = new EvoSuite();
String targetClass = StringUser.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());
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class PrivateReflectionSystemTest method testCoverageIssue.
private void testCoverageIssue() {
Properties.COVERAGE = true;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.LineCoverage;
do100percentLineTestOnStandardCriteria(CoverageIssue.class);
OutputVariable out = getOutputVariable(RuntimeVariable.LineCoverage);
double lineCov = (Double) out.getValue();
assertEquals(1d, lineCov, 0.01);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class StaticIntFieldSystemTest method test.
@Test
public void test() {
EvoSuite evosuite = new EvoSuite();
String targetClass = StaticIntField.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();
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 SystemTestBase method getOutputVariable.
protected OutputVariable getOutputVariable(RuntimeVariable rv) {
if (!Properties.OUTPUT_VARIABLES.contains(rv.toString())) {
throw new IllegalStateException("Properties.OUTPUT_VARIABLES needs to contain " + rv.toString());
}
Map<String, OutputVariable<?>> map = DebugStatisticsBackend.getLatestWritten();
Assert.assertNotNull(map);
OutputVariable out = map.get(rv.toString());
return out;
}
Aggregations