Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to retrieve code coverage metrics generated from OpenCover back to Jenkins?

I'm working on a .NET project that uses Jenkins as the CI server. The server is working as it's supposed to but now I'm trying to make it emit alerts in case of low code coverage.

The approach that I'm trying is to use Sonar to execute NUnit and OpenCover, but I need to link the code coverage metrics from Sonar back to Jenkins and that's where the problem resides.

AFAIK the report generated from OpenCover (coverage-report.xml) as is, is not recognized from Jenkins so what I'm trying to do is to make them talk by a xsl file that transforms the (coverage-report.xml) to a (emma-report.xml) that Jenkins has plugins that understands.

Although I don't know it that is the best approach. Better approaches are more than welcome ;) I'm facing a problem to get the block coverage metrics from OpenCover (Emma needs this metric).

I've managed to transform all other metrics needed class, %, method, % and line, % from OpenCover to Emma, but I'm not sure if is possible to get the block, % from the report.

Can anyone tell me if it is possible or if there is a better approach to achieve what I'm trying to do (that is, make Jenkins emit build alerts when code coverage is bellow a certain percentage)?

Thanks in advance! :)

like image 593
Matheus Avatar asked Sep 11 '12 12:09

Matheus


People also ask

How to see code coverage in Jenkins?

If you click on the Coverage Report icon, you will see code coverage for each package in your application, and even drill down to see the code coverage (or lack thereof) for an individual class (see Figure 2.31, “Jenkins lets you display code coverage metrics for packages and classes”).

What is OpenCover coverage?

OpenCover is an open source code coverage tool for . NET 2 and above. OpenCover is most commonly used to gather coverage data of code that is being exercised by unit testing (i.e. nunit, mstest etc.).

What is code coverage percentage?

Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.


1 Answers

It looks like there is now a tool to convert OpenCover reports to Covertura XML https://github.com/danielpalme/OpenCoverToCoberturaConverter/tree/master/OpenCoverToCoberturaConverter

The thread discussing this.

http://reportgenerator.codeplex.com/discussions/398788

like image 64
argatxa Avatar answered Sep 22 '22 17:09

argatxa