According to the part Ignore-Methods of the documentation of Stryker.NET it is possible to define methods and/or constructors to be skipped in the mutation like in the following example:
"stryker-config": {
"ignore-methods": [
"*Log", // Ignores all methods ending with Log
"Console.Write*", // Ignores all methods starting with Write in the class Console
"*Exception.ctor" // Ignores all exception constructors
]
}
Is it possible only to exclude internal constructors?
As a workaround I use the Stryker comments.
Nope.
Just to make things clear, the
ignore-methodoption doesn't ignore the code of the methods in question but the calls to them, or rather mutations in the calls to them.For example, in the following code, if you put
"ignore-methods": [ "Method2" ]in your config, your mutants will play out like this:On a technical side of things, Stryker works with Roslyn APIs and looks at the
ObjectCreationExpressionSyntax, not at theConstructorDeclarationSyntax(where it could theoretically distinguish constructors by the declared accessibility).So I guess it's not easy to propagate this kind of requirement to the Stryker core. Though - doable, hence you can create a feature request here. IMHO this is quite a niche ask.