Knowledge Base > DCover CLI > Generating HTML coverage reports

Generating HTML reports highlighting new coverage

To generate HTML reports highlighting new coverage, you first need to generate a JaCoCo report.

How to generate a JaCoCo report (Maven)

To generate a JaCoCo report in a Maven project:

1. Add the following declarations to the pom.xml file:


2. Run: mvn test

This creates a coverage report in binary format called jacoco.exec in the target directory of your Maven project. The report is also in XML,  HTML and CSV formats in the target/site/jacoco directory.

Please note that if you are generating a file to use with Diffblue Cover Reports, you need to use the report in XML format.

How to generate a JaCoCo report (Gradle)

To generate a JaCoCo report in a Gradle project:

1. Add the JaCoCo plugin to your build.gradle file:

apply plugin: 'jacoco'

2. Include the following configuration to enable the generation of the xml reports:

jacocoTestReport {
   dependsOn test
   reports {
       xml.enabled true
       csv.enabled true

3. To ensure that you run JaCoCo, we recommend adding finalizedBy jacocoTestReport to your test configuration, for example:

test {
    finalizedBy jacocoTestReport

Generating an HTML report with new coverage

Using dcover with the coverage-diff command generates a JaCoCo HTML report with the new coverage explicitly highlighted. In the example below, the new coverage is shown in blue in coverage bars.

For each coverage counter in the right portion of the table (cyclomatic complexity, lines, methods and classes) a column called Increased is added with the total number of newly covered elements.

To do this, run the following command from the root of the your project:

The instructions below assume you are using Maven. To use these instructions with Gradle, please replace target with build/jacoco

dcover coverage-diff target/jacocoOld.exec target/jacocoNew.exec

This generates the HTML report for a coverage report target/jacocoNew.ex, and highlights the increase in coverage compared to the coverage report target/jacocoOld.exec, in target/site/jacoco.

Additional optional arguments may also be provided for the coverage-diff command:

–classpath or -cp


-cp "my-project/target/classes"

Provide the path to class files of the project you want to generate the HTML report for. Multiple paths can be specified using : as separators for Linux/macOS and ; for Windows. All packages, classes and methods found in the listed directories and jar files will show in the generated report and at least all files of the project itself must be on the path. For example, if a jar with dependencies is provided then all packages and classes from the dependencies will be appear in the coverage report.

Default: target/classes

–source-dir or -s


-s "my-project/src/main/java"

Provide the relative path for the directory with source files. The source files are part of the HTML report and the coverage is marked using green and red lines. Note that at the moment, the newly covered lines are also shown in green, i.e., not distinguished from the old coverage.

Default: src/main/java

–report-output-dir or -d


-d "my-project/target/site/jacoco"

Provide the relative path for the directory where the HTML report should be saved.

Default: target/site/jacoco



--working-directory "my-project"

Set the working directory for running dcover, which should be the root directory of the project or module. If provided, all paths specified in other options should be either absolute or relative to the working directory. This is also used for setting the report header.

Default: .