use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class SpecialInspectorSystemTest method test.
@Test
public void test() {
EvoSuite evosuite = new EvoSuite();
String targetClass = SpecialInspector.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.BOOLEAN_TYPE);
boolean greaterthanZeroIsPure = purityAnalyzer.isPure(targetClass, "greaterThanZero", descriptor);
assertTrue(greaterthanZeroIsPure);
boolean notPureGreaterthanZeroIsPure = purityAnalyzer.isPure(targetClass, "notPureGreaterThanZero", descriptor);
assertFalse(notPureGreaterthanZeroIsPure);
boolean notPureCreationOfObjectIsPure = purityAnalyzer.isPure(targetClass, "notPureCreationOfObject", descriptor);
assertFalse(notPureCreationOfObjectIsPure);
boolean pureCreationOfObjectIsPure = purityAnalyzer.isPure(targetClass, "pureCreationOfObject", descriptor);
assertFalse(pureCreationOfObjectIsPure);
boolean superPureCall = purityAnalyzer.isPure(targetClass, "superPureCall", descriptor);
assertTrue(superPureCall);
boolean notPureGreaterThanZero = purityAnalyzer.isPure(AbstractInspector.class.getCanonicalName(), "notPureGreaterThanZero", descriptor);
assertFalse(notPureGreaterThanZero);
boolean superNotPureCall = purityAnalyzer.isPure(targetClass, "superNotPureCall", descriptor);
assertFalse(superNotPureCall);
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 testDoubleDefault.
@Test
public void testDoubleDefault() {
EvoSuite evosuite = new EvoSuite();
String targetClass = DoubleArrayDefault.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());
// Assert.assertTrue("Optimal coverage was not achieved ",
// best_fitness == 0.0);
}
use of org.evosuite.statistics.OutputVariable in project evosuite by EvoSuite.
the class ArrayDefaultSystemTest method testFloatPrimitiveDefault.
@Test
public void testFloatPrimitiveDefault() {
EvoSuite evosuite = new EvoSuite();
String targetClass = FloatPrimitiveArrayDefault.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 testFloatDefault.
@Test
public void testFloatDefault() {
EvoSuite evosuite = new EvoSuite();
String targetClass = FloatArrayDefault.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 testBooleanDefault.
@Test
public void testBooleanDefault() {
EvoSuite evosuite = new EvoSuite();
String targetClass = BooleanArrayDefault.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());
// Assert.assertTrue("Optimal coverage was not achieved ",
// best_fitness == 0.0);
}
Aggregations