【发布时间】:2018-08-29 18:49:43
【问题描述】:
我正在使用 OpenCover 来获取我的应用程序 .Net Core 中的测试覆盖率
当我运行 OpenCover 命令时,我的测试被执行,但没有访问任何类。此外,我的覆盖率始终为 0。
Total de testes: 2. Aprovados: 2. Com falha: 0. Ignorados: 0.
Execução de Teste Bem-sucedida.
Tempo de execução de teste: 7,6713 Segundos
Committing...
Visited Classes 0 of 18 (0)
Visited Methods 0 of 68 (0)
Visited Points 0 of 133 (0)
Visited Branches 0 of 74 (0)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 0 of 19 (0)
Alternative Visited Methods 0 of 92 (0)
我的 OpenCover 命令是这个:
"%LOCALAPPDATA%\Apps\OpenCover\OpenCover.Console.exe" -oldstyle -output:"%CD%\opencover.xml" -register:user -target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -targetargs:"InterpretadorFaleConoscoWexTests\bin\Debug\net461\InterpretadorFaleConoscoWexTests.dll"
我已经放了标签 <DebugType>Full</DebugType> ,尝试了有无 TestAdapterPath 和 oldStyle 等标签,没有人工作。我的覆盖率始终为 0。
谁能帮帮我?
我见过一些人有同样的问题。但是,没有解决我的问题的答案。
提前谢谢你。
编辑 1: 我尝试使用 -noshadow 参数,但我收到一条错误消息,指出这不是一个有效的参数。而官方文档here 并没有显示这个论点。所以也许它已被弃用,我不知道
【问题讨论】:
-
如果您能找到解决方案,请在此处发布
-
-noshadow是一个 xUnit 参数,因此如果您还没有尝试过,则需要将它放在targetargs中。 -
我尝试了一些方法,但没有成功。我试过
-targetargs:"(...)InterpretadorFaleConoscoWexTests.dll -noshadow"或-targetargs:"-noshadow (...)InterpretadorFaleConoscoWexTests.dll"但它总是返回错误。我该怎么办?
标签: .net testing code-coverage xunit opencover