【问题标题】:OpenCover filter not yielding any resultsOpenCover 过滤器没有产生任何结果
【发布时间】:2015-05-01 02:22:21
【问题描述】:

即使我尝试了一个非常简单的带有测试的控制台应用程序,我也无法让 Open Cover 中的过滤器参数正常工作。这是过滤器 - 我以管理员身份运行

这个:

"C:\Users\Mojo\AppData\Local\Apps\OpenCover\OpenCover.Console.exe" 
  -output:c:\coverage.xml -register:user 
  -target:"C:\TEMP\sonarqube-5.1\xunitRunner\xunit.console.exe" 
  -targetargs:"ConsoleApp.Tests.dll" 
  -filter:"+[ConsoleApp.*]* -[ConsoleApp.Tests]*"

产生这个:

    1) missing PDBs for the assemblies that match the filter please review the
    output file and refer to the Usage guide (Usage.rtf) about filters.
    2) the profiler may not be registered correctly, please refer to the Usage
    guide and the -register switch.

但是,如果我在没有过滤器的情况下运行它,我会得到覆盖结果:

"C:\Users\Mojo\AppData\Local\Apps\OpenCover\OpenCover.Console.exe" 
  -output:c:\coverage.xml -register:user 
  -target:"C:\TEMP\sonarqube-5.1\xunitRunner\xunit.console.exe" 
  -targetargs:"ConsoleApp.Tests.dll" 
Visited Classes 8 of 101 (7.92)
Visited Methods 20 of 305 (6.56)
Visited Points 52 of 1099 (4.73)
Visited Branches 27 of 958 (2.82)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 9 of 108 (8.33)
Alternative Visited Methods 28 of 416 (6.73)

我的控制台正在执行项目目录中的语句。

【问题讨论】:

    标签: opencover


    【解决方案1】:

    默认情况下,如果您不提供过滤器参数,OpenCover 将应用一些默认过滤器。

    如果您提供过滤器,则排除过滤器优先,然后包含过滤器具有最终排除默认值。

    过滤器的第一部分是模块[](通常这是程序集的名称,不包括文件扩展名),后一部分是名称空间/类型过滤器。

    如果不知道您的程序集/命名空间的所有名称,很难说出您的过滤器应该是什么,但请尝试

    -filter:"+[ConsoleApp]* -[ConsoleApp.Tests]*"
    

    -filter:"+[*]* -[ConsoleApp.Tests]*"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-18
      • 2023-03-15
      • 2016-01-28
      • 2017-07-08
      相关资源
      最近更新 更多