/** {@inheritDoc} */ @Override public void setChanged(boolean changed) { super.setChanged(changed); if (changed) { clearCachedResults(); } }
/** * <p> * setTestCase * </p> * * @param testCase * a {@link org.evosuite.testcase.TestCase} object. */ public void setTestCase(TestCase testCase) { test = testCase; clearCachedResults(); clearCachedMutationResults(); setChanged(true); }
/** * This method clears the cached results for a specific chromosome (e.g., fitness function * values computed in previous generations). Since a test case is changed via crossover * and/or mutation, previous data must be recomputed. * * @param chromosome TestChromosome to clean */ private void clearCachedResults(T chromosome) { ((TestChromosome) chromosome).clearCachedMutationResults(); ((TestChromosome) chromosome).clearCachedResults(); ((TestChromosome) chromosome).clearMutationHistory(); ((TestChromosome) chromosome).getFitnessValues().clear(); }
private static void reinstrument(TestSuiteChromosome testSuite, Properties.Criterion criterion) { if (ArrayUtil.contains(Properties.SECONDARY_OBJECTIVE, Properties.SecondaryObjective.IBRANCH)) { ExecutionTracer.enableContext(); } if (!ExecutionTracer.isTraceCallsEnabled()) { ExecutionTracer.enableTraceCalls(); } testSuite.setChanged(true); for (TestChromosome test : testSuite.getTestChromosomes()) { test.setChanged(true); test.clearCachedResults(); // clears last execution result and last mutation result } Properties.Criterion oldCriterion[] = Arrays.copyOf(Properties.CRITERION, Properties.CRITERION.length); Properties.CRITERION = new Properties.Criterion[]{criterion}; logger.info("Re-instrumenting for criterion: " + criterion); TestGenerationContext.getInstance().resetContext(); // Need to load class explicitly in case there are no test cases. // If there are tests, then this is redundant Properties.getInitializedTargetClass(); // TODO: Now all existing test cases have reflection objects pointing to the wrong classloader logger.info("Changing classloader of test suite for criterion: " + criterion); for (TestChromosome test : testSuite.getTestChromosomes()) { DefaultTestCase dtest = (DefaultTestCase) test.getTestCase(); dtest.changeClassLoader(TestGenerationContext.getInstance().getClassLoaderForSUT()); } Properties.CRITERION = oldCriterion; }
test.setTestCase(newTest); test.clearCachedResults();