【问题标题】:C# Coverlet results always emptyC# Coverlet 结果始终为空
【发布时间】:2020-07-02 22:58:34
【问题描述】:

拥有 .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

而标准输出表示 88 次测试在 4 秒内运行。我做错了什么?

【问题讨论】:

    标签: c# unit-testing .net-core coverlet


    【解决方案1】:

    对我来说,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。

    【讨论】:

    • 谢谢!这不是输出格式 - 但我缺少的关键是 /p:IncludeTestAssembly=true。现在它完美地工作了。
    猜你喜欢
    • 2020-08-24
    • 1970-01-01
    • 2019-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 2015-01-25
    相关资源
    最近更新 更多