我有一个大型的.NET Framework解决方案,并且希望开始收集代码覆盖率数据作为构建管道的一部分(以及在我们本地的开发人员机器上).
I have a large .NET Framework solution and want to start collecting code coverage data as part of our build pipeline (as well as on our local developer machines).
在Coverlet GitHub页面上,它说它支持.NET Framework项目,但是所有示例都使用 dotnet test CLI命令.
On the Coverlet GitHub page it says that it supports .NET Framework projects but all the examples are using the dotnet test CLI command.
是否可以为此使用Coverlet,还是应该查看OpenCover之类的东西?
Is it possible to use Coverlet for this or should I be looking at something like OpenCover?
推荐答案选项1
-
使用任务 Visual Studio测试
创建一个.runsettings文件并在.runsettings中配置Coverlet(请参阅 github/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md#coverlet-options-supported by-vstest-integration )
Create a .runsettings file and configure Coverlet in the .runsettings (see github/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md#coverlet-options-supported-by-vstest-integration)
参考任务中的.runsettings文件
Reference the .runsettings file in the task
勾选选项启用代码覆盖率
如果这不起作用,请使用发布代码覆盖率结果任务来发布由管理员生成的corbertura文件(默认名称: coverage.cobertura.xml ).测试任务
If this doesn't work, use a Publish code coverage results task, to publish the corbertura file (default name: coverage.cobertura.xml) produced by the test task
选项2
- 将以下NuGet软件包添加到您的测试项目中
- coverlet.msbuild
- Microsoft.NET.Test.Sdk
- Microsoft.TestPlatform
- Microsoft.TestPlatform.Build
- 使用 MSBuild 任务
- 使用以下命令行参数: < your-project> .csproj/p:CollectCoverage = true/t:VSTest
更多推荐
您可以使用Coverlet来获取.NET Framework项目中的代码覆盖率数据吗?
发布评论