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 cannot rollback node AspNetCore #298

Closed wmeints closed 5 years ago

wmeints commented 5 years ago

I'm trying to get Stryker.NET working on my code, but it can't mutate it properly. It chokes on compiling the code after it succesfully applied the mutations.

image

It seems like it can't find the types. There is a reference to the ASP.NET Core 2.2 package in my project. Additionally I've added the same reference to my test project in the hope that Stryker can find it. But it can't at the moment.

I've attached the log with trace level enabled to this issue.

debug.log

wmeints commented 5 years ago

Turns out that setting the projectName setting to an invalid value will cause the behavior. It would be nice if the tool checks that the project reference exists in the project file. This will trip people up :-)

rouke-broersma commented 5 years ago

We do check the project name for validity, apparently we missed a case. Seeing as you are using all default (auto detect project name under test) settings it seems like we have a regression in determining the project under test in the default configuration.

On Mon, Dec 31, 2018, 19:16 Willem Meints notifications@github.com wrote:

Turns out that setting the projectName setting to an invalid value will cause the behavior. It would be nice if the tool checks that the project reference exists in the project file. This will trip people up :-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stryker-mutator/stryker-net/issues/298#issuecomment-450676680, or mute the thread https://github.com/notifications/unsubscribe-auth/ADbenMEODa_9QLCk68PbhC_9VMMnndtwks5u-lRkgaJpZM4ZllRK .

wmeints commented 5 years ago

I should mention that I had a value for projectName explicitly set in the config file that pointed to ExampleProject.csproj. Which, I don't have obviously.

wmeints commented 5 years ago

I fixed it by removing the projectName setting, I don't need it since I have only one project reference in my test project.

richardwerkman commented 5 years ago

@wmeints What setting do you mean? The project-file setting in the stryker config? Or a setting in your csproj file. I now see it would be usefull to log the passed options to stryker as well.

vincentvanderwalt commented 5 years ago

Good morning,

I'm getting the same issue (Rollback mutation failure) but I'm getting it with Run and IWebHost.

[10:44:59 ERR] Unable to rollback mutation for node Run with diagnostic message 'IWebHost' does not contain a definition for 'Run' and no accessible extension method 'Run' accepting a first argument of type 'IWebHost' could be found (are you missing a using directive or an assembly reference?) [10:44:59 ERR] Unable to rollback mutation for node WebHost with diagnostic message The name 'WebHost' does not exist in the current context [10:44:59 ERR] An error occurred during the mutation test run System.ArgumentException: Node to track is not a descendant of the root.

I tried changing to .net core 2.2 but that doesn't work.

I tried setting the projectFile name as part of the parameters but that didn't help

dotnet stryker -p UnitTests.csproj

Any ideas ?

wmeints commented 5 years ago

@vinnytheviking The projectName can be found in the stryker-config.json file in the root of the project. It works without it, but I added it just in case I wanted to control additional settings.

rouke-broersma commented 5 years ago

@vinnytheviking Could you provide the full debug log?

vincentvanderwalt commented 5 years ago

Good morning.

I'm including the log as suggested by @Mobrockers

log-20190107.txt

vincentvanderwalt commented 5 years ago

@vinnytheviking The projectName can be found in the stryker-config.json file in the root of the project. It works without it, but I added it just in case I wanted to control additional settings.

@wmeints I couldn't get the stryker-config file to be picked up by the cli. I tried -cp etc but no luck

richardwerkman commented 5 years ago

@vinnytheviking Did you place the config file in the root folder of your test project? That's where stryker looks for the json file. Also I'm a bit confused by the log.

It looks like somehow the compiled project is missing important references to some .dll's. The compile errors in the log don't seem to be caused by any mutations. Could this be because of the .net core 2.2 preview? I don't think it's a coincidence that this issue was found just after the release of 2.2.

vincentvanderwalt commented 5 years ago

Hi @richardwerkman

I did put it in the root of the unit test project.

I tried changing the .net core version to an earlier version with no luck.

The project itself builds and runs fine, it's just stryker throwing those exceptions

richardwerkman commented 5 years ago

@vinnytheviking Could you send me a project to reproduce the issue? This friday I'll have time to look at this.

rouke-broersma commented 5 years ago

Seeing as @wmeints has found the issue and detecting this issue in the future has been improved by #307, I believe this issue can be closed. @wmeints @vinnytheviking Any objections? Anything else you think we should look at regarding this issue?

rouke-broersma commented 5 years ago

I am gonna close this issue. @vinnytheviking If you are still experiencing issues getting stryker to run on your project, feel free to open a new issue so we can take a look.