opencoverreportgenerator

OpenCover & ReportGenerator : History files are empty


I'm using OpenCover to successfully generate a code coverage xml report via MSTest. I'm driving it from Powershell/Bamboo. I then use ReportGenerator to successfully create the readable HTML report. It writes a coverage history file, but with zero content. (Upon subsequent runs, it will of course warn that it cannot read the history file as it is missing the root xml element, in fact it is missing everything.)

Where would I start looking to work out why the coverage history xml files are zero bytes?

Running from within the root of my project folder, my two expressions are generated thus:

C:\Users\...\OpenCover\OpenCover.Console.exe 
    -register:user
    -target:C:\...\MSTest.exe 
   "-targetargs:/testcontainer:.\webapi\WebApi.Tests\bin\Release\WebApi.Tests.dll /resultsfile:.\WebApiTestResults.trx /noisolation" 
   "-filter:+[*]* -[FluentValidation*]* -[Dapper*]* -[Antlr3*]*" 
    -mergebyhash 
    -output:.\projectCoverageReport.xml

And probably more pertinently the report generation expression:

C:\Tools\ReportGenerator_2.5.5\ReportGenerator.exe
    "-reports:projectCoverageReport.xml"
    "-targetdir:CodeCoverage"
    "-reportTypes:Html;HtmlChart;HtmlSummary"
    "-historydir:C:\OpenCoverHistory\VBN-YGWA"

Everything looks good, except the report generation. Permissions seem ok because the -historydir and path switch cause the creation of the directory, and of the blank files. I've run this as both Administrator on the machine (from within Powershell) and also as System via bamboo running the script. Same output.

Where would one go looking to figure out why the history files are zero bytes?


Solution

  • Your script looks fine. Please update ReportGenerator to version 2.5.6: https://www.nuget.org/packages/ReportGenerator/

    The version you are using has a bug regarding the history files. Sorry for that.