【问题标题】:Are there any open cover tools or extensions available for Visual Studio 2017?是否有任何可用于 Visual Studio 2017 的开放式封面工具或扩展?
【发布时间】:2018-07-26 10:05:25
【问题描述】:

我试图使用以下命令提取我的应用程序的覆盖率报告

OpenCover.Console.exe ^
-register:user ^
-target:"mstest.exe" ^
-targetargs:"/testcontainer:\"C:\myapp\bin\myapp.dll\" /resultsfile:\"myapp.trx\"" ^
-filter:"+[myapp*]* -[myapp.Test]* -[*]myapp.RouteConfig" ^
-mergebyhash ^
-skipautoprops ^
-output:"myapp.xml"

然后报告

.\ReportGenerator.exe ^
-reports:"F:\OpenCover\myapp.xml" ^
-targetdir:"ReportGenerator"

但是在运行 open cover 时出现以下错误?

我的命令有什么问题吗?

PS:我已经注册了open cover profiler

【问题讨论】:

    标签: c# visual-studio report code-coverage opencover


    【解决方案1】:

    我使用 mstest.exe 而不是 vstest.consoleopen cover 中运行测试用例

    这里是使用 open-cover 提取覆盖率报告的批处理文件代码 sn-p。

    ::Note:Before running this file, make sure opencover and reportgenerator installed in your system
    ::Download and read about opencover : https://github.com/OpenCover/opencover
    ::You can read about vstest.console command line documentation here https://msdn.microsoft.com/en-us/library/ms182486.aspx
    
    ::Set your project and report location's base path here
    SET basePath=C:\MyProject
    SET targetReportDir=F:\MyProject
    SET targetHtmlReportDir=F:\MyProject\ReportGenerator
    
    ::Replace your test project Dll's path here
    SET unitTestDlls=%basePath%\Demo.BusinessData\bin\Debug\Demo.BusinessData.Test.dll %basePath%\Demo.Cache.Test\bin\Debug\Demo.Cache.Test.dll
    
    
    echo Test cases are running...
    OpenCover.Console.exe -register:user -target:"vstest.console.exe" -targetargs:"%unitTestDlls%" -filter:"+[Demo*]* -[Demo*Test]* -[Demo*Test.Core]* -[Demo*Tests]*" -output:%targetReportDir%\DemoFullReport.xml -mergebyhash
    
    
    echo Coverage report is preparing and will be saved to %targetHtmlReportDir%\Demo location
    ReportGenerator.exe -reports:"%targetReportDir%\DemoFullReport.xml" -targetdir:"%targetHtmlReportDir%\Demo"
    

    运行此批处理文件前要检查的要点

    1. 确保在 Visual Studio 命令行中设置或运行 vstest.console 环境。
    2. 确保您的 opencover 已设置好并可通过命令行访问。
    3. 确保 opencover 报告生成器已设置并可通过命令行访问。

    谢谢

    【讨论】:

      猜你喜欢
      • 2018-08-01
      • 2018-05-13
      • 2012-11-11
      • 1970-01-01
      • 1970-01-01
      • 2023-02-21
      • 1970-01-01
      • 1970-01-01
      • 2018-02-28
      相关资源
      最近更新 更多