使用 ASP.Net Core 2.0 进行 OpenCover 覆盖率测试

3
我想使用OpenCover为在网站上执行的自动化/手动测试生成覆盖率报告(例如此链接)。我尝试了以下方法;
  1. Build the .net core 2 web app in the standalone mode and generate the exe.
    Use following to generate the report:

    C:\OpenCover\OpenCover.Console.exe -target:”C:\myproj\bin\Debug\myproj.exe” -output:C:\myproj\CoverageReports\myproj.results.xml -register:user
    

    This generates the report with empty results.

  2. Hosting in IIS 10. However it seems that opencover does not support IIS 10 yet.

使用opencover能否获取手动或自动化测试代码的覆盖率?


官方目前仍未完全支持-.NET Core Tool Support #601 未关闭。 作为另一种选择,考虑使用https://github.com/tonerdo/coverlet。 它具有opencover输出格式。 - Michael Freidgeim
1个回答

1

你应该在 .NET Core 中使用 -oldStyle:

C:\OpenCover\OpenCover.Console.exe -oldStyle -target:”C:\myproj\bin\Debug\myproj.exe” -output:C:\myproj\CoverageReports\myproj.results.xml -register:user

在你的项目中设置<DebugType>full</DebugType>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接