C# Coverlet 结果始终为空

Dar*_*key 4 c# unit-testing .net-core coverlet

有 .net core 3.1 Microsoft.net.sdk 项目,有大量异步 xUnit 测试。

  • 尝试- 将 coverlet.msbuild 2.9.0 添加到项目中,然后运行: dotnet test Common\Common.csproj /p:CollectCoverage=true / 显示 100%,但创建了一个空的覆盖文件
  • 尝试- 将 coverlet.collector 1.3.0 添加到项目中,然后运行: dotnet test Common\Common.csproj --collect:"XPlat Code Coverage" 在 testresults\{guid}\coverage.cobertura.xml 中创建了一个文件 - 但它只是说lines-covered=0

而 stdout 说 88 个测试在 4 秒内运行。我究竟做错了什么?

Yev*_*hin 7

对我来说 coverlet.msbuild 与命令完美配合: dotnet test Common\Common.csproj /p:CollectCoverage=true /p:IncludeTestAssembly=true /p:CoverletOutputFormat=cobertura /p:ExcludeByFile=\"**/Microsoft.NET.Test.Sdk.Program.cs\"

所以,我猜你在这里错过了 CoverletOutputFormat。

  • 谢谢你!这不是输出格式 - 但我_was_缺少的是关键是/p:IncludeTestAssembly=true。现在它工作得很好。 (3认同)
  • `/p:IncludeTestAssembly=true` 拯救了我的日子..!! (2认同)