Closed dupdob closed 2 months ago
I'm also having a hard time getting the new tests to pass when I run them locally, though it seems like they're passing in the CI/CD pipeline. Is there something I'm missing in my local setup? In case it helps, I'm getting errors like the following:
Failed ShouldNotMutateIfDisabledByMultilineComment [14 ms]
Error Message:
Test method Stryker.Core.UnitTest.Mutants.CsharpMutantOrchestratorTests.ShouldNotMutateIfDisabledByMultilineComment threw exception:
Shouldly.ShouldAssertException: isSame
should be
True
but was
False
Additional Info:
AST's are not equivalent. Line[9]
actual: if ((StrykerNamespace.MutantControl.IsActive(2)?!(condition && other):(StrykerNamespace.MutantControl.IsActive(1)?condition || other:condition && other))) /* Stryker disable once all */ {
expect: if ((StrykerNamespace.MutantControl.IsActive(0)?!(condition && other):(StrykerNamespace.MutantControl.IsActive(0)?condition || other:condition && other))) /* Stryker disable once all */ {
Actual(full):
using System;
using System.Collections.Generic;
using System.Text;
...
I'm also having a hard time getting the new tests to pass when I run them locally, though it seems like they're passing in the CI/CD pipeline. Is there something I'm missing in my local setup? In case it helps, I'm getting errors like the following:
Failed ShouldNotMutateIfDisabledByMultilineComment [14 ms] Error Message: Test method Stryker.Core.UnitTest.Mutants.CsharpMutantOrchestratorTests.ShouldNotMutateIfDisabledByMultilineComment threw exception: Shouldly.ShouldAssertException: isSame should be True but was False Additional Info: AST's are not equivalent. Line[9] actual: if ((StrykerNamespace.MutantControl.IsActive(2)?!(condition && other):(StrykerNamespace.MutantControl.IsActive(1)?condition || other:condition && other))) /* Stryker disable once all */ { expect: if ((StrykerNamespace.MutantControl.IsActive(0)?!(condition && other):(StrykerNamespace.MutantControl.IsActive(0)?condition || other:condition && other))) /* Stryker disable once all */ { Actual(full): using System; using System.Collections.Generic; using System.Text; ...
You should pull again the code. I usually amend commits to fix test errors and force push the PR. I do not expect people to pull the code until the factory is green and the PR is ready (and not draft).
You should pull again the code. I usually amend commits to fix test errors and force push the PR. I do not expect people to pull the code until the factory is green and the PR is ready (and not draft).
Thanks, that makes sense! I was just wanting to test out some of my own suggestions, so I'll keep that in mind if I run into the issue again.
Stryker comments may not be detected if they are within a syntax node
if (cond/* Stryker comment*/ition) {....}
: will have no effectif (condition) /* Stryker comment*/ {....}
: will have no effect
The wording here might be worth clarifying. In most cases, if a Stryker comment is within a syntax node, it may not apply to that syntax node, but it will often apply to at least one of that syntax node's descendants. In your first example, it might only apply to part of the condition expression, and perhaps not the part one would expect (unless it came before a parenthesized expression). In the second example, it wouldn't apply to the if-statement, but it would apply to the if-statement's block, since that is its own syntax node.
Stryker comments may not be detected if they are within a syntax node
if (cond/* Stryker comment*/ition) {....}
: will have no effectif (condition) /* Stryker comment*/ {....}
: will have no effect
This doc is wrong here (I fixed it in a recent commit). I wrote it before doing any discovery testing:
if (condition) /* Stryker comment*/ {....}
actually has an effect (on the if true block or statement)
The wording here might be worth clarifying....
Yes but no.
SomeMethod(true
/* Stryker disable all */,
"");
No effect here, the empty string will be mutated
SomeMethod(true,
/* Stryker disable all */
"");
Effect here, the empty string mutation will be ignored. Simply by moving the comma.
You and I and people familiar with AST in general and more specifically Roslyn will find this logical, but most people may just see a code style difference. My view:
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code
Add support for the so called multiline comments format (
/* comment */
) for Stryker comments. Updated the doc and provided some detailed explanation foronce
option. Note that the Stryker comment must still be on a single line.Multiline comments should work exactly line single line comments when put on a dedicated line.
Stryker attempts to associate comments within the line with the previous syntax node, that is:
if (condition) {/* Stryker comment*/;....}
: this comment will apply to the whole syntax blockif (/* Stryker comment*/ condition) {....}
: this comment will apply to the whole condition expressionStryker comments may not be detected if they are within a syntax node
if (cond/* Stryker comment*/ition) {....}
: will have no effectif (condition /* Stryker comment*/) {....}
: will have no effectFixes #3008