2012-09-25 20 views
6

我使用OpenCover http://nuget.org/packages/opencover并写了下面的批处理文件来运行单元测试和生成代码覆盖率统计PDB文件:当我运行该批处理文件OpenCover/NUnit的找不到

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 \调试\”

得到任何帮助,

感谢,

回答

8

找到了解决办法,我失踪nunit的/ noshadow开关。即目标参数应该是:

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

现在完美工作。

+0

谢谢,这有帮助。 – JoshGough

+0

这也帮助了我,谢谢! – willem

0

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

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

在openCover指定参数时,使用-register:user如果它不能正常工作使用-register:path32

0

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

随着Visual Studio 2015,请务必按照此处所述更新到最新版本的OpenCover。 - OpenCover/NUnit can't find PDB files

会为我节省一个小时的头痛。