How to setup JaCoCo code coverage with Maven & Gradle

Step by step configuration of the JaCoCo code coverage tool for Java project using Maven & Gradle build tools

Rafiullah Hamedy
8 min readJul 6, 2020
Source: https://dilbert.com/strip/2011-03-24

First of all, code coverage tools indicate what percentage of your codebase is covered by your tests.

In this article, we will actually get our hands dirty and add code coverage to a java project that uses Maven or Gradle build tool.

In the following article, I have briefly explained 10 reasons why code coverage plays a crucial role to a product’s quality and success in the long run.

There are many tools out there for different projects, and we will focus on JaCoCo, which stands for JavaCodeCoverage tool.

Java code coverage tools

There are different code coverage tools for different languages, and I am going to focus on Java. The most famous code coverages tools are

  1. JaCoCo — https://www.jacoco.org/jacoco/index.html

--

--

Rafiullah Hamedy

Staff software developer • Love to write • Over 250K views • Connect on linkedin.com/in/rhamedy • Medium referral https://medium.com/@rhamedy/membership