我正在尝试使用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 / 32bits。在那个主题上,不确定它是否与任何方式相关,但是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
我还试过了一个DLL项目(.net4),它由另一个项目(也是xunit)测试,结果相同(缺乏)。
任何帮助表示赞赏!
答案 0 :(得分:4)
下载发行包解决了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