stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.74k stars 177 forks source link

Ignored methods fail to exclude mutants within nested method calls or expressions #2964

Open chinchala opened 2 weeks ago

chinchala commented 2 weeks ago

Describe the bug The ignore-methods configuration feature is not effectively excluding specified mutants within nested method calls or expressions. Despite specifying certain methods to be ignored, mutants within nested contexts are still being generated, leading to unexpected mutation testing results.

Example:

"stryker-config": {
    "ignore-methods": ["LogInformation"]
}
logger.LogInformation("some text"); //all mutants ignored
logger.LogInformation(GetSomeText(true)); // mutant survived: logger.LogInformation(GetSomeText(false));
logger.LogInformation(logSensitiveData ? sensitive : baseRequest); //mutant survived: logger.LogInformation(!(logSensitiveData ) ? sensitive : baseRequest);

Expected behavior Mutants within nested method calls or expressions, where the outer method is specified in the ignore-methods configuration, should be ignored. Expected behavior for provided example:

logger.LogInformation("some text"); //all mutants ignored
logger.LogInformation(GetSomeText(true)); //all mutants should be ignored
logger.LogInformation(logSensitiveData ? sensitive : baseRequest); //all mutants should be ignored

Desktop (please complete the following information):