Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Coverage with Jenkins [closed]

I am being asked to use Jenkins to test code coverage for a Java Project. The issue is I have never used Jenkins and have scarcely little experience with actual code coverage. I have been searching a bit and I have come across JaCoCo and Cobertura as plugs. The issue is everything talking about them is above my head at this point. My question is this, as I understand it Jenkins and JaCoCo/Cobertura are used to run tests(Junit?), and report on how well the handle my code, but where do they get the test? Obviously I should make them, but what kind of files are these(again Junit?) and how do the tools get them?

If you are feeling generous, are there any good introduction level tutorials for these tools?

like image 824
EasilyBaffled Avatar asked Jun 15 '13 00:06

EasilyBaffled


People also ask

How does Jenkins show code coverage?

2:On the Jenkins dashboard, click on “Project Configuration,” scroll down, and click on the “Post-build Actions” from the drop-down options presented to you, click on the “Publish RKTracer Report.” If you have automated the process, the code coverage report will automatically get published on the Jenkins dashboard.

What should I exclude from code coverage?

The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class or some of its members are not planned to be covered with tests. EditFormModel class shown above can be left out from code coverage by simply adding the attribute.

How do I check my code coverage?

To calculate the code coverage percentage, simply use the following formula: 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

Maybe try looking in this direction:

  • May your project be maven project
  • Use Jenkins (you already do)
  • Use Sonar

Sonar:

  • More about: http://www.sonarsource.org/manage-code-coverage-by-unit-tests-with-sonar/
  • Download from: http://sonar-pkg.sourceforge.net/

There are lot of tutorials how to use Jenkins+Sonar so I guess you will not have much trouble. Sonar is really powerful tool, one of the best I've seen so far. And there is a plugin for Jenkins (but it can be avoided with certain profile in your maven project's pom.xml file).

like image 136
darijan Avatar answered Sep 30 '22 09:09

darijan