.net - 即使执行了测试,测试覆盖率也为 0% (Opencover/xUnit)

标签 .net testing code-coverage xunit opencover

我正在使用 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 开关吗?

关于.net - 即使执行了测试,测试覆盖率也为 0% (Opencover/xUnit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52084282/

相关文章:

javascript - 参数检查库

ios - TestFlight 中的测试说明

testing - java.lang.ClassNotFoundException : IntegrationSpec while running specs2 Tests in Intellij 14 异常

python - Pytest cov 不生成任何报告

c# - Visual Studio Code Coverage 在 vNext 项目中过时了吗?

c# - C# 中的 "protected"方法?

c# - 将html文件转换成PDF文件?

.net - 在 .net 中获取连接到 PC 的硬盘的唯一 ID

c# - 错误 - 与当前连接关联的事务已完成但尚未处理

google-chrome-devtools - Chrome 开发者工具 : I CSS Coverage unused bytes