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

DefineConstants are not parsed correctly #1076

Closed quackasaur closed 4 years ago

quackasaur commented 4 years ago

Stryker throws a compile error during the initial test run on vstest. No special configurations, just specified the path for my *.csproj file on cmd. Attached the file with logs on the cmd during test run. StrykerLogs.txt

Please let me know if you need additional information.

richardwerkman commented 4 years ago

Hi @kish0 thanks for submitting this issue. My first thought is that we read an empty value from your DefineConstants in your .csproj file. It could be possible it contains a value like: TRACE;DEBUG;. We split the value on ; and that will leave 3 constants: TRACE, DEBUG and ``. The last one could cause the error.

It could be possible that dotnet build filters the empty values and we do not. If that is the case we should probably filter them as well. Could you verify that the DefineConstants is the problem?

quackasaur commented 4 years ago

Hi @richardwerkman, as you suggested I removed DEBUG and TRACE constants from my project properties. But I still ended up with the same compile error.

If it helps, I am including a part .csproj file of unit test

csproj.txt

richardwerkman commented 4 years ago

Hi @kish0 I've succesfully reproduced the issue. It is caused by the DefineConstants property in your csproj.

However it would be located in your project under test and not your test project. To be clear, this is what the cause looks like:

    <DefineConstants>DEBUG;TRACE;</DefineConstants>

The last ; causes an empty value when we parse the constants. The correct value looks like:

    <DefineConstants>DEBUG;TRACE</DefineConstants>

You should be able to fix it by removing the last ;. Meanwhile we should filter empty values in Stryker to make sure this error doesn't happen again. 🚀

richardwerkman commented 4 years ago

This should be fixed in the next release, after the PR will be merged :)

quackasaur commented 4 years ago

Thanks for the help @richardwerkman