Integrate Jacoco With Maven

Integrate Jacoco With Maven


JaCoCo is a free Java code coverage library distributed under the Eclipse Public License and it is very simple to add to all types of build including ANT and Maven, and it is also very simple to add to Java containers or a standalone JVM.

Configure Jacoco with Maven

Add these properties tag to pom.xml

Add this plugins to pom.xml

Add a test method



run the application

To run the examples execute the following command.


The results are published in /target/site/jacoco.

We can drill through a more detailed view for each Java class:

Report Analysis

JaCoCo reports help to visually analyze code coverage by using diamonds colors for branches and background colors for lines:
Red diamond means that no branches have been exercised during the test phase.
Yellow diamond shows that the code is partially covered – some branches have not been exercised.
Green diamond means that all branches have been exercised during the test.

Source code

Author: Ayman Ben Amor

No Comments

Post a Comment