Adding OpenCover to the latest version of TeamCity (6.5) couldn't be easier however if you need help follow these simple steps.
-
Download and install OpenCover
-
Download and install ReportGenerator (actually unzip)
-
Register the OpenCover profiler DLLs using the regsvr32 utility
regsvr32 /s x86\OpenCover.Profiler.dll regsvr32 /s x64\OpenCover.Profiler.dll
-
Using TeamCity add a new Build Step to your configuration
-
Choose Command Line as the runner type then choose Custom Script for the Run option.
-
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
- 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.