use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class PublicFieldSystemTest method testPrimitiveFieldClass.
@Test
public void testPrimitiveFieldClass() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ClassWithPublicPrimitiveField.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.OUTPUT_VARIABLES = "" + RuntimeVariable.HadUnstableTests;
Properties.MINIMIZE = false;
Properties.ASSERTION_STRATEGY = Properties.AssertionStrategy.ALL;
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 ToStringInspectorSystemTest method testImpureToString.
@Test
public void testImpureToString() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ImpureToStringInspector.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);
double best_fitness = best.getFitness();
Assert.assertTrue("Optimal coverage was not achieved ", best_fitness == 0.0);
CheapPurityAnalyzer purityAnalyzer = CheapPurityAnalyzer.getInstance();
String descriptor = Type.getMethodDescriptor(Type.getType(String.class));
boolean toString = purityAnalyzer.isPure(targetClass, "toString", descriptor);
assertFalse(toString);
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 Base64SystemTest method testBase64.
@Test
public void testBase64() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Base64.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 ArrayDefaultSystemTest method testIntegerDefault.
@Test
public void testIntegerDefault() {
EvoSuite evosuite = new EvoSuite();
String targetClass = IntegerArrayDefault.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 CoverageAnalysisOfClassSystemTest method testMeasureCoverageOfCarvedTests.
@Test
public void testMeasureCoverageOfCarvedTests() {
EvoSuite evosuite = new EvoSuite();
String targetClass = MethodWithSeveralInputArguments.class.getCanonicalName();
String testClass = TestMethodWithSeveralInputArguments.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.INPUT, Properties.Criterion.METHOD, Properties.Criterion.OUTPUT };
String[] command = new String[] { "-class", targetClass, "-Djunit=" + testClass, "-Dselected_junit=" + testClass, "-measureCoverage" };
SearchStatistics result = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(result);
OutputVariable<?> methodCoverage = (OutputVariable<?>) result.getOutputVariables().get(RuntimeVariable.MethodCoverage.name());
OutputVariable<?> inputCoverage = (OutputVariable<?>) result.getOutputVariables().get(RuntimeVariable.InputCoverage.name());
OutputVariable<?> outputCoverage = (OutputVariable<?>) result.getOutputVariables().get(RuntimeVariable.OutputCoverage.name());
Assert.assertEquals("Unexpected method coverage value", 1d, (Double) methodCoverage.getValue(), 0.01);
Assert.assertEquals("Unexpected input coverage value", 0.67d, (Double) inputCoverage.getValue(), 0.01);
Assert.assertEquals("Unexpected output coverage value", 0.33d, (Double) outputCoverage.getValue(), 0.01);
}
Aggregations