EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
829 stars 340 forks source link

Suggestion - calculate best candidate fitness after evolving #396

Open saiema opened 2 years ago

saiema commented 2 years ago

Context

At least in MonotonicGA, the algorithm does something like this

double bestFitnessBeforeEvolution = getBestFitness();
evolve();
sortPopulation();
double bestFitnessAfterEvolution = getBestFitness();
//check that the best fitness after evolution is the same or better than the one before evolution

Suggestion

The issue is that if we use a fitness that has dynamic goals (goals are discovered during test generation) then the comparison is checking incomparable states. I suggest changing the code to

T bestCandidateBeforeEvolution = getBestCandidate();
evolve();
sortPopulation();
double bestFitnessBeforeEvolution = getBestFitness(bestCandidateBeforeEvolution);
double bestFitnessAfterEvolution = getBestFitness();
//check that the best fitness after evolution is the same or better than the one before evolution

This code should be semantically equivalent for any fitness with static goals, but it would also support those with dynamic goals