Replies: 3 comments 8 replies
-
Hi, I get why this is a point of discussion. Here is my view on this: When ignoring a method I expect the arguments passed to the method to be skipped from mutation. However, the return value of the invocation can be part of a mutation. I think your examples are a bit vague, as some of the mutations aren't even valid mutations (stryker doesn't swap expressions in conditional ternary expressions). I'll give some examples of what I expect to happen:
So in short: The invocation of the ignored method should stay exactly like it is, it shouldn't be removed and the arguments shouldn't be mutated. But side effects from the result of the ignored method should be mutated. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback
Sorry if they are vague, but all those are valid mutations in the general sens. How the filter behave should not be dictated by existing or upcoming mutators 😄 .
Here is my rationale
|
Beta Was this translation helpful? Give feedback.
-
Just added a unit test for those examples.
While I was expecting the last two to fail, I did not expect the simple 'x = IgnoredMethod();' to fail. |
Beta Was this translation helpful? Give feedback.
-
Context
This is a followup of issue #2653 where I realized that existing unit tests (for the IgnoreMethodFilter) were non representative.
I have been working on improving on the test, but I often face results I deem illogical.
The purpose of this discussion is to improve/narrow the expected behavior of this filter and improve doc and code accordingly.
Why
Because the question turns to be subtler than one could think at first: what means 'ignoring a method' ?
Analysis
The purpose of this option is to help users (of Stryker) ignore 'en masse' mutations they can not (or do not intend to) test for. An often given example is application logging, which is hard to test and rarely, if ever, tested. This happens also with console output (
Console.Write
) or concurrency related test (ConfigureAwait
).These methods share all an important characteristic: calling them result in some side effect(s) that is difficult to test for.
Hence I propose a refined description of the
Ignore
filter: it ignores mutations impacting only (side) effects from ignored methods.Concrete examples
For a given ignored method
M
.For expression mutations:
M
must be ignored : such asM(true)
toM(false)
. This is already the case in V 3.10.cond ? M(true) : M(false)
=>cond ? M(false) : M(true)
. This is not the case in V 3.10M() ? 1 : 2
=>M() ? 2 : 1
. This is not the case in V 3.10For statement mutations:
x = M()
) should follow Expression rules. This is the case in V 3.10.x = M()
) should follow Expression rules. This is not he case in V3.10For block mutations
Beta Was this translation helpful? Give feedback.
All reactions