Mutate constant expressions
See original GitHub issueIs your feature request related to a problem? Please describe. Currently, Stryker does not mutate constant expressions when assigned to fields
const int foo = 5 - 1;
With #1017, it will also not support mutating enum member declarations:
public enum Numbers
{
One = 1,
Two = (One + 1)
}
These syntax nodes are simply skipped, since Stryker will insert non-constant code during the mutation, which would cause code that does not compile:
public enum Numbers
{
One = 1,
// CS0133 The expression being assigned to 'MutantOrchestratorTests.Numbers.Two' must be constant
Two = StrykerXGJbRBlHxqRdD9O.MutantControl.IsActive(0) ? One + 1 : One - 1
}
Describe the solution you’d like Stryker should mutate constant expressions in a way they compile, so that
const int foo = 5 - 1;
becomes
const int foo = 5 + 1;
This is a valid mutation that would break a piece of software and should be covered by unit tests. Therefore, it should be supported by Stryker to generate these kinds of mutations.
Probably deep changes are needed here, since generally, a ternary expression is inserted when mutating code. Instead, the code needs to be modified without inserting more function calls.
Describe alternatives you’ve considered Instead of changing the mutation generation for all code, constant expressions could be handled in a different way, but that would lead to an inconsistent code base without much benefit.
Additional context To avoid warnings until this feature is implemented, Issue #1016 and Pull Request #1017 have been created to skip EnumMemberDeclarationSyntax nodes. Otherwise, they would produce warnings when using Stryker on code containing those nodes.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
I think the easiest way to do this would be simply to build multiple assemblies. I dont think switching variable names would work. Consider this
switching would mean something like
Switching enum implies polymorphism.
But having one assembly per mutant take care of everything, at the expense of run time. This could be considered as ‘intense’ mutation testing.
But IMHO, I am not sure this is a good direction. The point of Stryker is to generate the most interesting mutant, trying to find gaps in test. Not generating every possible alternate version of an assembly just so user can brag on how many mutants their tests kill.
I agree the idea is horrible once you start working out the implications :p