stryker-mutator / stryker-net

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

Unable to rollback mutation #269

Closed klemmchr closed 5 years ago

klemmchr commented 5 years ago

Stryker fails to rollback mutations for several nodes.

Version 0.7.0 (beta)

[10:48:59 INF] Using C:\foo\bar.csproj as project file
[10:48:59 INF] Starting initial build
[10:49:04 INF] Initial build successful
[10:49:05 INF] Using testrunner DotnetTestRunner
[10:49:05 INF] Initial testrun started
[10:49:40 INF] Total number of tests found in initial test run: 0
[10:49:40 INF] Initial testrun successful in 34437 ms
[10:49:40 INF] Using 81655 ms as testrun timeout
[10:49:41 INF] 949 mutants created
[10:49:43 ERR] Unable to rollback mutation for node reader with diagnostic message Der Name "reader" ist im aktuellen Kontext nicht vorhanden.
[10:49:43 ERR] Unable to rollback mutation for node command with diagnostic message Der Name "command" ist im aktuellen Kontext nicht vorhanden.
[10:49:43 ERR] Unable to rollback mutation for node mySqlConnection with diagnostic message Der Name "mySqlConnection" ist im aktuellen Kontext nicht vorhanden.
[10:49:43 ERR] Unable to rollback mutation for node mySqlConnection with diagnostic message Der Name "mySqlConnection" ist im aktuellen Kontext nicht vorhanden.
[10:49:43 ERR] An error occurred during the mutation test run
System.ArgumentException: Der aufzuzeichnende Knoten ist kein untergeordnetes Element des Stamms.
   at Microsoft.CodeAnalysis.SyntaxNodeExtensions.TrackNodes[TRoot](TRoot root, IEnumerable`1 nodes) in /_/src/Compilers/Core/Portable/Syntax/SyntaxNodeExtensions_Tracking.cs:line 43
   at Stryker.Core.Compiling.RollbackProcess.RemoveMutantIfStatements(SyntaxTree originalTree, ICollection`1 diagnosticInfo)
   at Stryker.Core.Compiling.RollbackProcess.Start(CSharpCompilation compiler, ImmutableArray`1 diagnostics)
   at Stryker.Core.Compiling.CompilingProcess.Compile(IEnumerable`1 syntaxTrees, MemoryStream ms)
   at Stryker.Core.MutationTest.MutationTestProcess.Mutate()
   at Stryker.Core.StrykerRunner.RunMutationTest(StrykerOptions options)
[10:49:43 INF] Time Elapsed 00:00:43.7736487

We have some database integration tests in our unit tests. Maybe this is related to the error. The unit tests arre running fine when using dotnet test

richardwerkman commented 5 years ago

This error should have nothing to do with your test project. Could you run again with --log-console trace to find more information about what kind of mutation causes this error?

klemmchr commented 5 years ago

As this output contains the code itself (and therefore sensitive parts) I'm not allowed to post the output here. I may send it to a member privately.

richardwerkman commented 5 years ago

It may not be needed to send parts of the code. If you can create a simple example project that recreates the issue we could work with that.

If you can't recreate the issue you may send the output to my email and I'll look into it.

klemmchr commented 5 years ago

I've send you a mail.

richardwerkman commented 5 years ago

Thank you, using your output I've been able to reproduce the issue locally.

using System.Threading.Tasks;

namespace Test
{
    public class ExampleBug
    {
        public async Task<(string, string)> ExampleBugMethod()
        {
            var (one, two) = await ExampleTupleMethod().ConfigureAwait(true);

            return (one, two);
        }

        private async Task<(string one, string two)> ExampleTupleMethod()
        {
            return ("test1", "test2");
        }
    }
}

Using var (tuple) seems to cause the issue. This was already known as seen in #125 but was closed without verifiying if the issue was actually fixed.

I'll try to create a PR for this today 👍