use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class ImpureInspectorSystemTest method test.
@Test
public void test() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ImpureInspector.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.INT_TYPE);
boolean recursivePureFunction = purityAnalyzer.isPure(targetClass, "recursivePureFunction", Type.getMethodDescriptor(Type.INT_TYPE, Type.INT_TYPE));
assertTrue(recursivePureFunction);
boolean getImpureValue = purityAnalyzer.isPure(targetClass, "getImpureValue", descriptor);
assertFalse(getImpureValue);
boolean getPureValue = purityAnalyzer.isPure(targetClass, "getPureValue", descriptor);
assertTrue(getPureValue);
boolean getImpureValueFromCall = purityAnalyzer.isPure(targetClass, "getImpureValueFromCall", descriptor);
assertFalse(getImpureValueFromCall);
boolean getPureValueFromCall = purityAnalyzer.isPure(targetClass, "getPureValueFromCall", descriptor);
assertTrue(getPureValueFromCall);
boolean recursivePureInspector = purityAnalyzer.isPure(targetClass, "recursivePureInspector", descriptor);
assertTrue(recursivePureInspector);
boolean recursiveImpureInspector = purityAnalyzer.isPure(targetClass, "recursiveImpureInspector", descriptor);
assertFalse(recursiveImpureInspector);
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 ListContainerUserSystemTest method testContainerUser.
@Test
public void testContainerUser() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ListContainerUser.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 MockInConstructorSystemTest method testInstrumentConstructorCall.
@Test
public void testInstrumentConstructorCall() {
EvoSuite evosuite = new EvoSuite();
String targetClass = DateInConstructor.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 ExitVMSystemTest method testRuntimeUser.
@Test
public void testRuntimeUser() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ExitVM.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 MapContainerUserSystemTest method testContainerUser.
@Test
public void testContainerUser() {
EvoSuite evosuite = new EvoSuite();
String targetClass = MapContainerUser.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