Teamcity opencover integration


We run our tests as part of the test phase of every build which constructs an NUnit console command and executes it in parallel with all test assemblies, failing the build if the tests fail. Using parameter arguments we can instruct this phase to run the tests through a coverage tool. Currently we support both dotcover and opencover which basically wraps these command in the corresponding coverage command. This all works very well and when using dotcover we publish teamcity messages for the coverage reports e.g. "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='MYPATH']" which then gives us the summary view and coverage tab in Team City. Unfortunately the version of NUnit we use can return -100 on the console on a successful run (''). When running directly we just ignore this exit code. When running with opencover we use '-returntargetcode' to get the NUnit return code and again ignore the -100. Dotcover however doesn't currently have this feature and returns -3 for target failure. I have submitted this to dotcover and they have created a feature request to return the nunit return code on request rather the targets code being hidden ( For now this pretty much limits our dotcover useage.

My question is: Is there a way that I can get the Opencover reports to be processed by teamcity messages rather than dotcover which will display the equivalent screens as dotcover does. The documentation ( seems to suggest that only dotcover, partcover, ncover or ncover3 are supported. I can see that there is a plugin to run opencover ( but running opencover isn't the issue we just need the reports processing and displaying as dotcover does. We already currently run report generator over the coverage.xml files and add the generated index.htm file and supporting files to a Teamcity tab. What I am wanting is the team city summary screen (Picture attached) and coverage tab which you get when using the other tools..

Comment actions Permalink


OpenCover is not supported by TeamCity. please watch/vote for related feature request.
To add the code coverage summary you can use the following service messages:

##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='15064']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='9522']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='3142']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='1826']
##teamcity[buildStatisticValue key='CodeCoverageAbsCTotal' value='394']
##teamcity[buildStatisticValue key='CodeCoverageAbsCCovered' value='281']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='68430']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='42765']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='4995']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='2151']

You can find keys description here. Also see this section.
Coverage tab (CoverageMain.jpg screenshot) should be created as .html file and published as an artifact (you can find an example of this page in dotCover hidden artifact).

Comment actions Permalink

Ok thanks, how do I vote for the feature 'TW-37205 Support OpenCover for .NET Code Coverage'

Comment actions Permalink

To vote for an issue you need to register and press "Vote for the issue" button at right bottom corner of issue description ("thumb up" icon).


Please sign in to leave a comment.