当我尝试用下面的命令运行Stryker时,它失败了,说它找不到.csproj
文件。文件存在于配置的位置,但是:
C:UsersMeDocumentsgitmy_pkg>dotnet stryker --solution-path ".My.Project.sln" --test-runner DotnetTest --project-file ".testMy.Project.TestsMy.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:UsersMeDocumentsgitmy_pkg
为什么找不到文件?
-项目文件应该指向要变异的项目,而不是单元测试项目。也就是说,如果My.Project.csproj是您正在测试的项目,而My.Project.Tests.csproj[/em>是附带的单元测试,那么我通常要做的是导航到包含My.Project.Tests.cproj的文件夹,并从命令行运行dotnet stryker
。如果My.project.Tests.csproj中只有一个项目引用,它将被自动检测到,Stryker将尝试创建突变体来检查您的单元测试项目。如果My.project.Tests.csproj文件中有多个项目引用,则系统将要求您通过传递-项目文件来澄清要更改的项目。
就我个人而言,我会在单元测试项目的根目录中创建一个stryker-config.json,如下所示:https://github.com/stryker-mutator/stryker-net/blob/master/docs/Configuration.md
你可能想要这样的东西:
{
"stryker-config": {
"reporters": [
"progress",
"html"
],
"log-level": "info",
"log-file": true,
"timeout-ms": 10000,
"project-file": "My.Project.csproj",
"max-concurrent-test-runners": 4,
"threshold-high": 80,
"threshold-low": 70,
"threshold-break": 60,
"mutation-level": "Standard",
"excluded-mutations": [
"string"
],
"dashboard-compare": false
}
}
假设在单元测试项目中引用了My.Project.csproj。