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

Does not work with Rider / .NET Core 2.1? #222

Closed natalie-o-perret closed 5 years ago

natalie-o-perret commented 5 years ago

I followed the tutorial given https://stryker-mutator.io/stryker-net/quickstart applied to Rider and turns out that the CLI part cannot be installed:

NU1202: Package StrykerMutator.DotNetCoreCli 0.4.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package StrykerMutator.DotNetCoreCli 0.4.0 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
NU1212: Invalid project-package combination for StrykerMutator.DotNetCoreCli 0.4.0. DotnetToolReference project style can only contain references of the DotnetTool type 
Package restore failed. Rolling back package changes for [...]

Which leads me to think that it's issue regarding the version (2.1) of .NET Core I am using for that (xUnit) Test Project.

Any idea?

rouke-broersma commented 5 years ago

Yes, apologies. We tried to add dotnet global tool support in the previous release, but we did not notice that this broke the dotnet CLI extension tool support. We have reverted this change but need to release a new package for it. In the mean time you could use version 0.3.0 or install stryker as a global dotnet tool instead of a package reference in your project.

rouke-broersma commented 5 years ago

@ehouarn-perret Version 0.5.0 of Stryker has been published and includes the fix for this issue. It should be available on nuget.org within the next 15 minutes - half hour.

natalie-o-perret commented 5 years ago

@ehouarn-perret Version 0.5.0 of Stryker has been published and includes the fix for this issue. It should be available on nuget.org within the next 15 minutes - half hour.

Wosh, you're really awesome!

simondel commented 5 years ago

@Mobrockers for some reason the changelog for 0.5.0 was not properly generated :confused:

natalie-o-perret commented 5 years ago

@Mobrockers I tried running dotnet stryker and got that


   _____ _              _               _   _ ______ _______ 
  / ____| |            | |             | \ | |  ____|__   __|
 | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |   
  \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |   
  ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |   
 |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|   
                   __/ |                                   
                  |___/                                    

Beta version

[16:18:34 INF] Using /home/perret/Desktop/Tests/Playground/Domain/Domain.Core.Tests/Domain.Core.Tests.csproj as project file
[16:18:34 ERR] An error occurred during the mutation test run 
System.NotSupportedException: No project references found in test project file, unable to find project to mutate.
   at Stryker.Core.Initialisation.ProjectFileReader.FindProjectReference(XDocument document, String projectUnderTestNameFilter)
   at Stryker.Core.Initialisation.ProjectFileReader.ReadProjectFile(XDocument projectFileContents, String projectUnderTestNameFilter)
   at Stryker.Core.Initialisation.InputFileResolver.ReadProjectFile(String projectFilePath, String projectName)
   at Stryker.Core.Initialisation.InputFileResolver.ResolveInput(String currentDirectory, String projectName)
   at Stryker.Core.Initialisation.InitialisationProcess.Initialize(StrykerOptions options)
   at Stryker.Core.StrykerRunner.RunMutationTest(StrykerOptions options)
[16:18:34 INF] Time Elapsed 00:00:00.1369693
perret@perret-ThinkPad-E460:~/Desktop/Tests/Playground/Domain/Domain.Core.Tests$ 

I tried while being in a folder with a dummy test project containing just one very dumb test.

simondel commented 5 years ago

With mutation testing we make changes to your source code and test the outcome using your test project.

It looks like your test project contains no reference to another project that may contain your source code. Because of that, Stryker.NET cannot find any code to mutate.

natalie-o-perret commented 5 years ago

With mutation testing we make changes to your source code and test the outcome using your test project.

It looks like your test project contains no reference to another project that may contain your source code. Because of that, Stryker.NET cannot find any code to mutate.

I know it's sort of dirty (playing without an external referenced project) but say I have a test project, so Stryker can't mutate the entities in that same project? Necessarily need to have another external one referenced to that test project? My point is more "are good practices really enforced in the CLI"?

Side note, imagine that someone crafts an entity in the test project for some random methods taking generics and testing with at some point some reflection things on it. I think it's legit for testing the generic stuff to have testing entities which are not used in the external project (I confess it's a bit of a corner case).

I close the thread since the issue is now solved. However, it would be interesting to have your thoughts on the "limitation" when tests depend on entities (mostly for type/reflection powered entities) defined within the test project itself.

rouke-broersma commented 5 years ago

@ehouarn-perret We do not currently have any way to manually specify files to mutate, but your case should be possible once we have this feature.