7

我正在使用 OpenCover http://nuget.org/packages/opencover并编写了以下批处理文件来运行单元测试并生成代码覆盖率统计信息:

echo off

echo ***************************
echo *** Running NUnit tests ***
echo ***************************
"..\packages\OpenCover.4.0.804\OpenCover.Console.exe" -register:user -target:"..\NUnit 2.6\bin\nunit-console-x86.exe" -targetargs:"..\Web.UnitTests\bin\Debug\Web.UnitTests.dll"  -output:coverage.xml

echo **************************************
echo *** Generating coverage statistics ***
echo **************************************
"..\packages\ReportGenerator.1.6.0.0\ReportGenerator.exe" "-reports:coverage.xml" "-targetdir:%CD%"

echo ***********************************
echo *** Launching Internet Explorer ***
echo ***********************************
start "C:\Program Files (x86)\Internet Explorer\iexplore.exe" "%CD%\Index.htm"

pause

但是,当我运行批处理文件时,出现错误:

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)

很确定我做了一些愚蠢的事情/遗漏了一些明显的事情,但不确定是什么!

PDB 文件位于文件夹中:“..\Web.UnitTests\bin\Debug\”

感谢任何帮助,

谢谢,

4

3 回答 3

8

找到了解决方案,我错过了 nunit 的 /noshadow 开关。即目标参数应该是:

-targetargs:"..\Web.UnitTests\bin\Debug\Web.UnitTests.dll /noshadow"

现在完美运行。

于 2012-09-26T08:03:56.507 回答
1

注册 opencover DLL(使用 x86 或 x64 DLL):

regsvr32 /n /i:user C:OpenCover.4.5.3723\x86\OpenCover.Profiler.dll

在 openCover 参数中,-register:user如果它不起作用,请使用-register:path32.

于 2016-04-10T10:16:23.937 回答
0

我知道您的问题已解决,但我遇到了与您类似的问题。我已经完成了 /noshadow 的事情。

使用 Visual Studio 2015,请确保按照此处的说明更新到最新版本的 OpenCover。- OpenCover/NUnit 找不到 PDB 文件

本来可以为我节省一个小时的头痛。

于 2016-08-04T18:06:00.653 回答