Search code examples
filebatch-fileopencoverreportgenerator

Code Coverage with OpenCover and ReportGenerator


I'm trying to set up the batch file to use OpenCover and ReportGenerator for the first time but I can't get it to work.

I have checked a few examples of batch files and the OpenCover and ReportGenerator documentation and my batch file seems to be in line with these. I can't figure out where I am going wrong.

REM Make a 'Reports' directory if it doesn't exist already
mkdir .\reports
REM Run unit tests through OpenCover
.\packages\OpenCover.4.6.519\tools\OpenCover.Console.exe^
 -register:user^
 -target:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe"^
 -targetargs:"/noisolation/testcontainer:\"C:\Users\Michael\Google Drive\FDM Dev Course Content\Workspace\BookStoreTDD\UnitTests\bin\Debug\UnitTests.dll""^
 -mergebyhash^
 -output:.\reports\output.xml
REM Generate the report
.\packages\ReportGenerator.2.5.6\tools\ReportGenerator.exe^
 -reports:.\reports\output.xml^
 -targetdir:.\reports
REM Open the report
start .\reports\index.htm

Could anyone please tell me where I am going wrong?


Solution

  • It looks like you need a space after /noisolation and you need to escape a quote to close the end of the the -targetargs e.g. \"" – Shaun Wilde