Skip to content

Mutant generation strategies

DurieuxPol edited this page Apr 11, 2024 · 3 revisions

Mutant generation strategies are objects that describe a way to generate mutants for the analysis. They also rely on a mutant selection strategy to shuffle the mutant collection before returning it.
There are 4 types of strategies:

MTAllMutantGenerationStrategy

This is the default mutant generation strategy used by the analysis.
This strategy generates mutant from all methods of all the classes of the analysis.
To use this strategy:

analysis mutantGenerationStrategy: MTAllMutantGenerationStrategy new

MTSelectingFromCoverageMutantGenerationStrategy

This strategy uses only the methods covered by tests to generate mutants. It can make the analysis faster, as there will be less mutants to evaluate.
To use this strategy:

analysis mutantGenerationStrategy: MTSelectingFromCoverageMutantGenerationStrategy new

MTManualMutatedMethodMutantGenerationStrategy

This strategy uses a specific method collection given at instance creation to generate mutants.
To use this strategy and give it a method collection named "methodCollection":

analysis mutantGenerationStrategy: MTManualMutatedMethodMutantGenerationStrategy new targetMethods: methodCollection

MTManualMutantGenerationStrategy

This strategy doesn't really generate mutants by itself, it simply returns the mutant collection it was given at instance creation. It is designed to be used in some specific tests, but it can absolutely be used in regular analysis as well.
To use it with a mutant collection called "mutantCollection":

analysis mutantGenerationStrategy: MTManualMutantGenerationStrategy new mutations: mutantCollection

Check this page to know more about the mutant selection strategies.