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

Stryker.NET failed to mutate your project #593

Closed alexanderkozlenko closed 5 years ago

alexanderkozlenko commented 5 years ago

Summary

Stryker failed to analyse a solution with the message No .csproj file found. Command line used:

dotnet stryker --solution-path Anemonis.JsonRpc.sln -l debug -f

Logs

  1. log-20190622.txt
  2. stryker-console.log

Expected behavior

Stryker succeeded to analyse a solution.

Environment

Additional context

The example project: https://github.com/alexanderkozlenko/json-rpc

rouke-broersma commented 5 years ago

Hey! Stryker currently needs to be run from the context of the unit test project (we have plans to change this in the future). Could you try running stryker from https://github.com/alexanderkozlenko/json-rpc/tree/master/src/Anemonis.JsonRpc.UnitTests ?

Also the solution file path is not required for dotnet core.

alexanderkozlenko commented 5 years ago

@Mobrockers, thank for the quick response! I managed to run Stryker, however, faced another issue, could you please take a look?

stryker-file-not-found.log

rouke-broersma commented 5 years ago
[20:13:47 INF] Using C:\git\json-rpc\src\Anemonis.JsonRpc.UnitTests\Anemonis.JsonRpc.UnitTests.csproj as project file
[20:14:00 INF] Started initial build using dotnet build
[20:14:04 INF] Initial build successful
[20:14:12 INF] Using testrunner VsTest
[20:14:12 INF] Initial testrun started
[20:14:13 INF] Total number of tests found in initial test run: 381
[20:14:13 INF] Time Elapsed 00:00:26.1349482
Stryker.NET failed to mutate your project. For more information see the logs below:

Initial testrun was not successful.

Assert.AreEqual failed. Expected:<1.1>. Actual:<1,1>.

It seems like one of your unit tests is locale specific so the unit test fails on my system. It also fails for me in visual studio. We require all unit tests work for stryker to run to avoid unreliable results.

image

rouke-broersma commented 5 years ago

Another issue I found was the following:

image

Stryker uses Environment.GetEnvironmentVarible() to detect which mutation is enabled for this testrun. It seems like this method is actually not available in netstandard 1.1. When we find multiple TargetFrameworks in project we simply choose to take the first in the list. The first in the list in your project is 1.1 so this method that stryker injects into your project is not available :|

You can work around this be swapping <TargetFrameworks>netstandard1.1;netstandard2.0</TargetFrameworks> with <TargetFrameworks>netstandard2.0;netstandard1.1</TargetFrameworks>

rouke-broersma commented 5 years ago

@alexanderkozlenko I ran your project for you. I got it working by commenting out the one unit test that was failing for me, then changing the order of the targetframeworks in the csproj.

C:\git\json-rpc\src\Anemonis.JsonRpc.UnitTests> dotnet stryker -tr vstest -r "['ConsoleProgressBar', 'Html']"

Here's your result, pretty good! mutation-report.zip

alexanderkozlenko commented 5 years ago

@Mobrockers, thank you for very detailed response and a found issue in unit tests! I assume the issue can be closed, since I have good instructions how to run Stryker.NET on my project.

FYI: I suppose there is a small issue with navigation in HTML report (at least with Google Chrome and Mozilla Firefox): navigation fails if source file name contains 0x60 ASCII character. There are two such entries in the attached report.

rouke-broersma commented 5 years ago

Could you create an issue for the html report here: https://github.com/stryker-mutator/mutation-testing-elements