Is there a way to get code coverage metrics from OpenCover to Jenkins?

I am working on a .NET project that uses Jenkins as a CI server. The server works as intended, but now I'm trying to get it to issue warnings in case of low code coverage .

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

An AFAIK report created using OpenCover ( cover-report.xml ), as it is, is not recognized from Jenkins , so I'm trying to get them to say xsl, which converts ( cover-report.xml ) to ( emma-report.xml ) Jenkins has plugins that understand.

Although I do not know, this is the best approach. More efficient approaches are more than welcome;) I ran into the problem of getting block coverage metrics from OpenCover ( Emma needs this metric).

I managed to convert all the other metrics needed by class, % , method, % and line, % from OpenCover to Emma , but I'm not sure if you can get block, % from the report.

Can someone tell me if this is possible, or if there is a better approach to achieving what I am trying to do (i.e. make Jenkins emit build warnings when the code coverage is below a certain percentage)

Thanks in advance!:)

+7
source share
2 answers

If you are using OpenCover from the sonar gallio plugin (from the C # ecosystem of the sonar), a simple solution to get warnings about low code coverage can be the sonar build breaker plugin . You will get a broken assembly when the coverage is below the warning threshold. This solution does not allow you to get a chart or trends in Jenkins, but again, if you use sonar, you have everything in the sonar panels. Hope this helps.

+1
source
+3
source

All Articles