xunit - opencover + xunit 没有结果

标签 xunit opencover

我试图使用 OpenCover(今天下载)来覆盖我的测试。这是我使用的命令行:

OpenCover.Console.exe -target:"c:\Programmes2\xunit\xunit.console.clr4.x86.exe" -targetargs:"""C:\Sources\Project\BackOffice.Tests\bin\Debug\BackOffice.Tests.dll"" /noshadow " -output:bo.coverage.xml -targetdir:"C:\Sources\Project\BackOffice.Tests\bin\Debug" -filter:+[*]*

这是我得到的输出
xUnit.net console test runner (32-bit .NET 4.0.30319.269)
Copyright (C) 2007-11 Microsoft Corporation.

xunit.dll:     Version 1.9.0.1566
Test assembly: C:\Sources\Project\BackOffice.Tests\bin\Debug\BackOffice.Tests.dll

31 total, 0 failed, 0 skipped, took 2.760 seconds
Committing...
No results - no assemblies that matched the supplied filter were instrumented
    this could be due to missing PDBs for the assemblies that match the filter
    please review the output file and refer to the Usage guide (Usage.rtf)

生成的报告始终相同:
<?xml version="1.0" encoding="utf-8"?>
<CoverageSession xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Modules />
</CoverageSession>

更多上下文:PDB 存在于目标文件夹中,我以管理员身份运行命令提示符。测试的项目是一个 .net 4/mvc 3 应用程序。我的电脑运行的是 Windows 7/32 位。在该主题上,不确定这是否有任何相关性,但是即使我强制目标平台为 x86,其中的 x86 文件夹也是空的。

此外,当我尝试使用 regsvr32 注册 OpenCover.Profiler.dll 时,我收到一条错误消息,指出该 dll 可能与我的 Windows 版本不兼容。

如果我尝试使用 -register 或 -register:user 参数,则会出现异常:
An exception occured: Failed to register(user:True,register:True,is64:False):3 the profiler assembly; you may want to look into permissions or using the -register:user option instead. C:\Windows\system32\regsvr32.exe /s  /n /i:user "C:\Sources\Opencover\sawilde-opencover-be6e491\main\bin\Debug\x86\OpenCover.Profiler.dll"
stack:    
    à OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register, Boolean is64) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 59
    à OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 45
    à OpenCover.Framework.ProfilerRegistration.Register(Boolean userRegistration) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Framework\ProfilerRegistration.cs:ligne 31
    à OpenCover.Console.Program.Main(String[] args) dans C:\Sources\Opencover\sawilde-opencover-be6e491\main\OpenCover.Console\Program.cs:ligne 82

我还尝试了一个由不同项目(xunit 也是)测试的 DLL 项目(.net4),结果相同(缺乏)。

任何帮助表示赞赏!

最佳答案

下载release包解决了register参数的异常。但是运行相同的命令行会产生多个此类错误:

BackOffice.Tests.HomeControllerShould.Redirect_To_Action_Feed_Index [FAIL]
   System.MissingMethodException : Méthode introuvable : 'Void     System.CannotUnloadAppDomainException.SafeVisited(Int32)'.
   Stack Trace:
      à BackOffice.Tests.HomeControllerShould..ctor()

结果如下:
31 total, 31 failed, 0 skipped, took 0.241 seconds
Committing...
Visited Classes 0 of 44 (0)
Visited Methods 0 of 183 (0)
Visited Points 0 of 1352 (0)
Visited Branches 0 of 322 (0)

==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 53 (0)
Alternative Visited Methods 0 of 268 (0)

四处寻找类似的问题后,我找到了this issue on github并尝试了 -oldStyle 参数。它解决了我的。

@Shaun Wilde,如果您有机会再次看到这个问题,您能告诉我们这是否是解决它的推荐方法,以及我们是否会因“正常”方式使用它而失去某些东西(我还建议将此参数添加到documentation page

关于xunit - opencover + xunit 没有结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10735248/

相关文章:

java - Junit - 比较两个 XML 文档是否相同

c# - Asp.net 核心 - 未找到 dotnet 测试

.net - 我如何使用 OpenCover 连接到服务?

sonarqube - (sonar with gallio and) opencover,代码覆盖率 : 0%

unit-testing - PLUnit 中的 xUnit 导出支持

c# - 网络核心: Find Application Assembly Location from Integration Test

c# - xUnit.net:未运行测试类构造函数?

C# ASP.NET 代码覆盖率 - OpenCover 无结果

cruisecontrol.net - 在 CruiseControl.NET 中提供 OpenCover 报告

.net - OpenCover 未涵盖实际源代码