@Test public void testResetWithAssertionGenerationAll() { 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; 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()); }
@Test public void test() { EvoSuite evosuite = new EvoSuite(); String targetClass = JdkPureInspector.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 equalsToZ = purityAnalyzer.isPure(targetClass, "equalsToZ", descriptor); assertTrue(equalsToZ); boolean isLowerCase = purityAnalyzer.isPure(targetClass, "isLowerCase", descriptor); assertTrue(isLowerCase); 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()); }