use of org.evosuite.ga.metaheuristics.GeneticAlgorithm in project evosuite by EvoSuite.
the class PrivateReflectionSystemTest method testPrivateConstructor.
private TestSuiteChromosome testPrivateConstructor() {
Properties.P_REFLECTION_ON_PRIVATE = 0.9;
Properties.REFLECTION_START_PERCENT = 0.0;
GeneticAlgorithm ga = do100percentLineTestOnStandardCriteriaWithMethodTrace(PrivateConstructor.class);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
assertTrue(!best.getTests().isEmpty());
double cov = best.getCoverageInstanceOf(MethodCoverageSuiteFitness.class);
Assert.assertEquals("Non-optimal method coverage: ", 1d, cov, 0.001);
Optional<FitnessFunction<?>> ff = ga.getFitnessFunctions().stream().filter(m -> m instanceof MethodCoverageSuiteFitness).findAny();
assertEquals(1, best.getNumOfCoveredGoals(ff.get()));
cov = best.getCoverageInstanceOf(MethodTraceCoverageSuiteFitness.class);
Assert.assertEquals("Non-optimal method trace coverage: ", 1d, cov, 0.001);
ff = ga.getFitnessFunctions().stream().filter(m -> m instanceof MethodTraceCoverageSuiteFitness).findAny();
assertEquals(1, best.getNumOfCoveredGoals(ff.get()));
return best;
}
use of org.evosuite.ga.metaheuristics.GeneticAlgorithm in project evosuite by EvoSuite.
the class NoveltyFitnessEvaluationListener method iteration.
@Override
public void iteration(GeneticAlgorithm<?> algorithm) {
List<TestChromosome> population = ((GeneticAlgorithm<TestChromosome>) algorithm).getPopulation();
TestSuiteChromosome suite = createMergedSolution(population);
for (FitnessFunction fitnessFunction : fitnessFunctions) {
fitnessFunction.getFitness(suite);
}
// Update fitness functions based on goals just added to archive
algorithm.updateFitnessFunctionsAndValues();
}
Aggregations