You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'd like to use ignore-methods to ignore calls to exception constructors, as I'm not interested in testing the contents of exception messages. This works when the exception message appears in a new Exception("...") expression, but not when the exception message appears in a call to base or this from another constructor.
Expected behavior
Since base and this are both means of invoking constructors, I feel they should be ignored by the same settings that would ignore direct calls to those same constructors. For example, if my ignore-methods setting contains the string "*Exception.ctor", then I expect Stryker to ignore calls to this from constructors of classes whose name matches the string "*Exception", as well as calls to base from constructors of classes which extend classes whose name matches the string "*Exception".
Desktop (please complete the following information):
OS: Windows
Type of project: Microsoft.NET.Sdk
Framework Version: net8.0
Stryker Version: 4.1.0
Additional context
Here is the source code I've used to reproduce this issue:
BaseConstructorIssueDemo.cs
namespaceLibraryProject;publicclassBaseConstructorIssueDemo{publicvoidThrowException1(){thrownewSomeException("This is an exception message.");}publicvoidThrowException2(){thrownewSomeException(false);}publicvoidThrowException3(){thrownewSomeException();}publicvoidThrowException4(){thrownewException("Some text.");}}publicclassSomeException:Exception{publicSomeException():base("Default message"){}publicSomeException(boolvalue):this($"Value: {value}"){}publicSomeException(stringmessage):base(message){}}
thanks for your detail reporting. Indeed, base call constructor are not considered as constructor invocation and it appears to be a bug.
Before engaging into a fix, I would like to stress out that you will still need to add to ignore methods the constructor for SomeException. Are you comfortable with this?
As a work around, you can use Stryker comments to disable mutations around constructors. You an use online documentation on how to use them.
thanks for your detail reporting. Indeed, base call constructor are not considered as constructor invocation and it appears to be a bug. Before engaging into a fix, I would like to stress out that you will still need to add to ignore methods the constructor for SomeException. Are you comfortable with this? As a work around, you can use Stryker comments to disable mutations around constructors. You an use online documentation on how to use them.
I imagine that if I have an entry in ignore-methods like "*Exception.ctor" (note the *), that any call to the constructors of SomeException, Exception, or any other class ending in "Exception" would all be ignored. I would assume that in the case of SomeException's constructors, any call to this would be ignored due to SomeException.ctor matching *Exception.ctor, and any call to base would be ignored due to the constructors of its base class (i.e., Exception.ctor) also matching the same pattern. Does that line up with your understanding, @dupdob?
Yes, thank you. I just wanted to make it clear that there would be no class hierarchy search. this was identified as to be supported as well. That being said, fixing this requires redesigning significant parts of Stryker.
Describe the bug
I'd like to use
ignore-methods
to ignore calls to exception constructors, as I'm not interested in testing the contents of exception messages. This works when the exception message appears in anew Exception("...")
expression, but not when the exception message appears in a call tobase
orthis
from another constructor.Logs
log-20240808.txt
Expected behavior
Since
base
andthis
are both means of invoking constructors, I feel they should be ignored by the same settings that would ignore direct calls to those same constructors. For example, if myignore-methods
setting contains the string "*Exception.ctor", then I expect Stryker to ignore calls tothis
from constructors of classes whose name matches the string "*Exception", as well as calls tobase
from constructors of classes which extend classes whose name matches the string "*Exception".Desktop (please complete the following information):
Additional context
Here is the source code I've used to reproduce this issue:
BaseConstructorIssueDemo.cs
BaseConstructorIssueDemoTests.cs
stryker-config.json
The text was updated successfully, but these errors were encountered: