Open cover generates no output on coverage details

Ravindra picture Ravindra · Jul 24, 2011 · Viewed 10k times · Source

trying to run the open cover as below

opencover.console.exe -target:"C:\Users\rkapiset\Downloads\xunit-1.8\xunit.console.clr4.x86.exe" -targetargs:"""E:\Office\CRM\dotnet\1 - UI\EYC.CRM.UI.Tests\bin\Debug\EYC.CRM.UI.Tests.dll""" -filter:+[EYC]* -output:coverage.xml

below is the result

61 total, 3 failed, 0 skipped, took 1.674 seconds
Visited Classes 0 of 0 (NaN)
Visited Methods 0 of 0 (NaN)
Visited Points 0 of 0 (NaN)
Unvisited Classes
Unvisited Methods

Any hints where i'm going wrong? thanks in advance.

Answer

cocogorilla picture cocogorilla · Sep 25, 2015

There are a couple of keys to getting this to work.

  1. find open cover
  2. tell it to use xunit.console.exe
  3. give it arguments for xunit.console.exe using targetargs
  4. give xunit the debug versions of both the test dll and application dll
  5. instruct xunit to NOT use a shadowcopy (so all PDB debug files are available in its working directory)
  6. comment quotes in paths in targetargs with a backslash
  7. filter out classes in the ".Tests" project from coverage
  8. use -register to do something magical
  9. run as administrator (not an issue if UAC is turned off on your machine)

Example:

"C:\OpenCover.4.6.166\tools\OpenCover.Console.exe" -output:"C:\MyProject\coverage.xml" "-target:C:\MyProject\packages\xunit.runner.console.2.0.0\tools\xunit.console.exe" -targetargs:"\"C:\MyProject\Project.Tests\bin\Debug\Project.Tests.dll\" \"C:\MyProject\Project\bin\Debug\Project.exe\" -noshadow" -filter:"+[*]Project.* -[*.Tests]*" -register

Cite: http://derekwilson.net/derekblog/post/2012/05/29/Using-OpenCover-and-xUnit.aspx