@Test public void testWithSearchObjective(){ TestFitnessFunction testFF = Mockito.mock(TestFitnessFunction.class); Mockito.when(testFF.isCovered(testSuite.getTestChromosome(0))).thenReturn(true); ArrayList<TestFitnessFunction> coverageGoals = new ArrayList<>(); coverageGoals.add(testFF); Properties.MINIMIZE = false; TestFitnessFactory testFitnessFactory = Mockito.mock(TestFitnessFactory.class); Mockito.when(testFitnessFactory.getCoverageGoals()).thenReturn(coverageGoals); Mockito.when(testFitnessFactory.getCoverageGoals()).thenReturn(coverageGoals); ArrayList testFitnessFactoryList = new ArrayList(); testFitnessFactoryList.add(testFitnessFactory); PostProcessUtility.postProcessTests(testSuite, testFitnessFactoryList); assert(testSuite.getTests().size() == 1); }
public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) { LOG.info("test size before post-process: {}",testSuite.size()); if (Properties.INLINE) { ConstantInliner inliner = new ConstantInliner(); inliner.inline(testSuite); } if (Properties.MINIMIZE) { double before = testSuite.getFitness(); TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories); LOG.info("* Minimizing test suite"); minimizer.minimize(testSuite, true); double after = testSuite.getFitness(); if (after > before + 0.01d) { throw new Error("EvoSuite bug: minimization lead fitness from " + before + " to " + after); } } LOG.info("test size after post-process: {}",testSuite.size()); if (Properties.ASSERTIONS) { LOG.info("Generating assertions"); TestSuiteGeneratorHelper.addAssertions(testSuite); } compileAndCheckTests(testSuite); }
PostProcessUtility { public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) { LOG.info("test size before post-process: {}",testSuite.size()); if (Properties.INLINE) { ConstantInliner inliner = new ConstantInliner(); inliner.inline(testSuite); } if (Properties.MINIMIZE) { double before = testSuite.getFitness(); TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories); LOG.info("* Minimizing test suite"); minimizer.minimize(testSuite, true); double after = testSuite.getFitness(); if (after > before + 0.01d) { throw new Error("EvoSuite bug: minimization lead fitness from " + before + " to " + after); } } LOG.info("test size after post-process: {}",testSuite.size()); if (Properties.ASSERTIONS) { LOG.info("Generating assertions"); TestSuiteGeneratorHelper.addAssertions(testSuite); } compileAndCheckTests(testSuite); } }
PostProcessUtility { public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) { LOG.info("test size before post-process: {}",testSuite.size()); if (Properties.INLINE) { ConstantInliner inliner = new ConstantInliner(); inliner.inline(testSuite); } if (Properties.MINIMIZE) { double before = testSuite.getFitness(); TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories); LOG.info("* Minimizing test suite"); minimizer.minimize(testSuite, true); double after = testSuite.getFitness(); if (after > before + 0.01d) { throw new Error("EvoSuite bug: minimization lead fitness from " + before + " to " + after); } } LOG.info("test size after post-process: {}",testSuite.size()); if (Properties.ASSERTIONS) { LOG.info("Generating assertions"); TestSuiteGeneratorHelper.addAssertions(testSuite); } compileAndCheckTests(testSuite); }  }
PostProcessUtility { public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) { LOG.info("test size before post-process: {}",testSuite.size()); if (Properties.INLINE) { ConstantInliner inliner = new ConstantInliner(); inliner.inline(testSuite); } if (Properties.MINIMIZE) { double before = testSuite.getFitness(); TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories); LOG.info("* Minimizing test suite"); minimizer.minimize(testSuite, true); double after = testSuite.getFitness(); if (after > before + 0.01d) { throw new Error("EvoSuite bug: minimization lead fitness from " + before + " to " + after); } } LOG.info("test size after post-process: {}",testSuite.size()); if (Properties.ASSERTIONS) { LOG.info("Generating assertions"); TestSuiteGeneratorHelper.addAssertions(testSuite); } compileAndCheckTests(testSuite); }  static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories); static TestGenerationResult writeJUnitTestsAndCreateResult(TestSuiteChromosome testSuite, String suffix); static void writeJUnitFailingTests(); }
PostProcessUtility { public static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories) { LOG.info("test size before post-process: {}",testSuite.size()); if (Properties.INLINE) { ConstantInliner inliner = new ConstantInliner(); inliner.inline(testSuite); } if (Properties.MINIMIZE) { double before = testSuite.getFitness(); TestSuiteMinimizer minimizer = new TestSuiteMinimizer(fitnessFactories); LOG.info("* Minimizing test suite"); minimizer.minimize(testSuite, true); double after = testSuite.getFitness(); if (after > before + 0.01d) { throw new Error("EvoSuite bug: minimization lead fitness from " + before + " to " + after); } } LOG.info("test size after post-process: {}",testSuite.size()); if (Properties.ASSERTIONS) { LOG.info("Generating assertions"); TestSuiteGeneratorHelper.addAssertions(testSuite); } compileAndCheckTests(testSuite); }  static void postProcessTests(TestSuiteChromosome testSuite, List<TestFitnessFactory<? extends TestFitnessFunction>> fitnessFactories); static TestGenerationResult writeJUnitTestsAndCreateResult(TestSuiteChromosome testSuite, String suffix); static void writeJUnitFailingTests();  }