When I try to run Stryker with the below command it fails saying it can't find a .csproj
file. The file exists at the configured location though:
C:\Users\Me\Documents\git\my_pkg>dotnet stryker --solution-path ".\My.Project.sln" --test-runner DotnetTest --project-file ".\test\My.Project.Tests\My.Project.Tests.csproj"
_____ _ _ _ _ ______ _______
/ ____| | | | | \ | | ____|__ __|
| (___ | |_ _ __ _ _| | _____ _ __ | \| | |__ | |
\___ \| __| '__| | | | |/ / _ \ '__| | . ` | __| | |
____) | |_| | | |_| | < __/ | | |\ | |____ | |
|_____/ \__|_| \__, |_|\_\___|_| (_)|_| \_|______| |_|
__/ |
|___/
Version: 0.20.0 (beta)
[10:41:49 INF] Time Elapsed 00:00:00.8016192
Stryker.NET failed to mutate your project. For more information see the logs below:
No .csproj file found, please check your project directory at C:\Users\Me\Documents\git\my_pkg
Why is the file not found?
--project-file should point to the project you intend to mutate, not the unit test project. That is, if My.Project.csproj is the project you are testing and My.Project.Tests.csproj are the accompanying unit tests, then what I would normally do is navigate to the folder containing the My.Project.Tests.csproj and run
dotnet stryker
from the command line. If there is only one project reference in the My.Project.Tests.csproj it will be automatically detected and Stryker will attempt to create mutants to check your Unit Test project. If there are multiple project references in the My.Project.Tests.csproj file, then you will be asked to clarify which project you intend to mutate by passing the --project-file.Personally I would create a stryker-config.json in the root of your unit testing project, as shown here: https://github.com/stryker-mutator/stryker-net/blob/master/docs/Configuration.md
You probably want something like this:
Assuming My.Project.csproj is referenced in your unit test project.