Category: Cobertura

Java Application Code Coverage with Cobertura + maven

Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage.

In this article, i am going to show you how to use Cobertura for maven based java application for measuring the code coverage by test cases.

 

Cobertura Code Coverage Report

Go to the root of the project and run the following command  that will analyze the code coverage with Cobertura and generate the output report (showing the detailed analysis of coverage).

mvn cobertura:cobertura

 

Screen Shot 2018-03-01 at 10.07.44 AM.png

 

Accessing the report

The generated code coverage analysis report can be accessed through  ${project}/target/site/cobertura/index.html 

Screen Shot 2018-03-01 at 10.13.38 AM.png