首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用opencover + xunit没有结果

使用opencover + xunit没有结果
EN

Stack Overflow用户
提问于 2012-05-24 18:02:05
回答 1查看 4K关注 0票数 11

我试着使用OpenCover (今天下载的)来获取我的测试的覆盖率。下面是我使用的命令行:

代码语言:javascript
复制
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:+[*]*

这是我得到的输出

代码语言:javascript
复制
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)

生成的报告总是相同的:

代码语言:javascript
复制
<?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/MVC3应用程序。我的电脑运行的是Windows7/32位。关于这个主题,我不确定这是否与此相关,但是即使我强制目标plateform为x86,中的x86文件夹也是空的。

此外,当我尝试向regsvr32注册OpenCover.Profiler.dll时,我得到一个错误,指出该dll可能与我的windows版本不兼容。

如果我尝试使用-register或-register:user参数,我会得到一个异常:

代码语言:javascript
复制
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),结果相同(缺少)。

感谢任何人的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-30 20:25:28

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

代码语言:javascript
复制
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()

结果如下:

代码语言:javascript
复制
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

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10735248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档