opencover

Adding OpenCover to TeamCity

Adding OpenCover to the latest version of TeamCity (6.5) couldn't be easier however if you need help follow these simple steps....

Shaun Wilde
acrobatic aircraft in formation above a city

Adding OpenCover to the latest version of TeamCity (6.5) couldn't be easier however if you need help follow these simple steps.

  1. Download and install OpenCover

  2. Download and install ReportGenerator (actually unzip)

  3. Register the OpenCover profiler DLLs using the regsvr32 utility

regsvr32 /s x86\OpenCover.Profiler.dll regsvr32 /s x64\OpenCover.Profiler.dll

  1. Using TeamCity add a new Build Step to your configuration

  2. Choose Command Line as the runner type then choose Custom Script for the Run option.

  3. Now all is needed is to set up the command to run the profiler against your tests e.g. for OpenCover the working directory is set to** main\bin\debug** and so we have

"%env.ProgramFiles(x86)%\opencover\opencover.console.exe" "-target:......\tools\NUnit-2.5.10.11092\bin\net-2.0\nunit-console-x86.exe" -targetargs:"OpenCover.Test.dll /noshadow" -filter:"+[Open*]* -[OpenCover.T*]*" "-output:......\opencovertests.xml"

"%env.ProgramFiles(x86)%\ReportGenerator\bin\ReportGenerator.exe" ......\opencovertests.xml ......\coverage

  1. Finally setup the artifacts so that you can view the results in TeamCity e.g.

%teamcity.build.workingDir%\opencovertests.xml %teamcity.build.workingDir%\coverage\**\*.*

And there you have it, OpenCover running under TeamCity and visual reports provided by ReportGenerator. I am sure you will find ways to improve upon this for your own builds.