Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open cover generates no output on coverage details

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.

like image 777
Ravindra Avatar asked Jul 24 '11 07:07

Ravindra


2 Answers

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

like image 125
cocogorilla Avatar answered Sep 19 '22 17:09

cocogorilla


Have you registered the profiler?

try the -register switch or if under UAC -register:user

All the switches are explained on the OpenCover Wiki

Alternative you can use regsvr32 on each of the profilers OpenCover.Profiler.dll in the x86 and x64 folders in the installed program files folder

like image 32
Shaun Wilde Avatar answered Sep 22 '22 17:09

Shaun Wilde