3

I am trying to use open cover to generate code coverage reports for my project, but it only covers test classes, not the source ones that I want. I am using the following command to run my tests:

"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -register:user -target:"$nunit_path\nunit-console.exe" -targetargs:"$project_path\Project.Test\Project.Test.dll -noshadow"  -mergebyhash -output:C:\Reports\NUnit\projectCoverageReport.xml

$nunit_path and $project_path are just the paths to my files, I skipped them to make the command clearer.

When I run this command, I get the full coverage of the test classes (inside the Project.Test.dll assembly) but nothing else. How do I make OpenCover consider the source code as well?

SalysBruoga
  • 875
  • 1
  • 9
  • 21
  • Did you ever end up finding an answer to this question? – summea Mar 23 '17 at 23:10
  • I'm no longer working at the place where I needed this solved, so I can't really remember how I solved it :/ I think we ended up using this software, but this problem just kind of sorted itself out, can't remember how. Sorry :/ – SalysBruoga Mar 28 '17 at 17:55

1 Answers1

5

One possible reason for this issue is the way pdb files are configured for that particular project. OpenCover expects the pdb files to be in their 'full' form rather than in 'portable' form. By default, visual studio marks pdb files as 'portable'. You can check this by doing following..

Right click on project -> proerties -> build -> Output -> Advanced -> debugging information.

Here the value should be 'full'.

Sateesh Pagolu
  • 9,282
  • 2
  • 30
  • 48
  • `Pdb-only` is enough to generate the test-coverage-report. – anion Sep 30 '20 at 17:47
  • 1
    I needed Full in Visual Studio 2019 with a .NET Framework 4.7.2 project. Not sure why the above is not more highly rated. Very useful, thank you. – Mike Upjohn Nov 19 '20 at 15:51