Search code examples
c#opencoverreportgenerator

OpenCover / ReportGenerator struggling to get the -coverbytest working. even when I dupe a particular test


Sorry guys just started using this the other day. I too am struggling to get the -coverbytest working.

Below are the two command I am running to get results. I have tried the and reread the documentation and found conflicting usage for the command lines. OpenCover is in the system path. I only want to run the Integration tests. I have also duplicated a test to ensure I am seeing the same code executed for two of the same test. This should produce the covered by icon (pinnned picture seen) but I am not getting stats. Any help would be appreciated. Great tool BTW. and I am getting stats out just not the test covered by dets.

OpenCover.Console.exe -register:user "-filter:+[BusinessLayer*]* -coverbytest:+[Test]*" "-target:C:\Repo\ThirdParty\NUnit.Runners.2.6.4\tools\nunit-console.exe" "-targetargs:/noshadow C:\Repo\UnitTests\Server\BusinessLayer.Tests\bin\Debug\BusinessLayerTests.dll /include:IntegrationTests" "-output:reports.xml"

C:\Repo\ThirdParty\ReportGenerator.2.3.5.0\tools\ReportGenerator.exe "-reports:TestResult.xml;reports.xml" "-targetdir:C:\Repo\UnitTests\Server\BusinessLayer.Tests\CodeCoverage" "-historydir:C:\Repo\UnitTests\Server\BusinessLayer.Tests\CodeCoverage\History" "-reporttypes:Html;HtmlSummary"


Solution

  • I always use "-coverbytest:*". That works fine for me. Are you sure that your quotation marks are correct (quotation marks between -filter and -coverbytest might be missing)? You should try:

    OpenCover.Console.exe -register:user "-filter:+[BusinessLayer*]*" "-coverbytest:*" "-target:C:\Repo\ThirdParty\NUnit.Runners.2.6.4\tools\nunit-console.exe" "-targetargs:/noshadow C:\Repo\UnitTests\Server\BusinessLayer.Tests\bin\Debug\BusinessLayerTests.dll /include:IntegrationTests" "-output:reports.xml"