Skip to main content
Version: QB70

Publish JaCoCo Report

To publish JaCoCo report, you only need two steps:

  1. Generate JaCoCo XML report from Ant or Maven or any other build tool.
  2. Add JaCoCo publish step by choosing Publish -> JaCoCo Report from step menu.
warning

The JaCoCo should be version 0.6.1 or higher.

Generate JaCoCo Report

QuickBuild will NOT generate JaCoCo report automatically, so first make sure the JaCoCo report is produced by ANT or by any other build tool. The following example shows how to generate JaCoCo coverage XML report with Ant Cobertura task, you may find more examples from JaCoCo website:
JaCoCo coverage report target in build.xml

<target name="test" depends="compile">
<!-- Step 2: Wrap test execution with the JaCoCo coverage task -->
<jacoco:coverage destfile="${result.exec.file}">
<java classname="org.jacoco.examples.parser.Main" fork="true">
<classpath path="${result.classes.dir}" />
<arg value="2 * 3 + 4"/>
<arg value="2 + 3 * 4"/>
<arg value="(2 + 3) * 4"/>
<arg value="2 * 2 * 2 * 2"/>
<arg value="1 + 2 + 3 + 4"/>
<arg value="2 * 3 + 2 * 5"/>
</java>
</jacoco:coverage>
</target>

<target name="report" depends="test">
<!-- Step 3. Create coverage report -->
<jacoco:report>

<!-- This task needs the collected execution data and ... -->
<executiondata>
<file file="${result.exec.file}" />
</executiondata>

<!-- the class files and optional source files ... -->
<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${result.classes.dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}" />
</sourcefiles>
</structure>

<!-- to produce reports in XML formats. -->
<xml destfile="${result.report.dir}/report.xml" />
</jacoco:report>
</target>

The code snippet will generate the JaCoCo report will be captured to '${result.report.dir}/report.xml'.

warning

When generating the report, please also make sure the source directory is under your configuration workspace directory. Otherwise, QuickBuild will fail to find the source code and will not be able to open the source code later.

Publish JaCoCo Report

Add Publish JaCoCo Report step to your build workflow. You can category your coverage report by adding multiple steps with different report set name(category name). Reference this page for how to use report set.

If the JaCoCo is published successfully, the build overview page will display the summary for your coverage,

and JaCoCo report tab will be displayed in your build page like below:

below shows the coverage of source code opening from class report or method report:

Configure Coverage Threshold

You may also change the JaCoCo coverage threshold for each configuration. Go to Configuration Settings / Report Settings / JaCoCo Setting:

then change to your threshold and configure the color you want.

Aggregate JaCoCo Report

Like all other reports, JaCoCo coverage data can be aggregated to current configuration and parent configuration, please refer to this page for how to add aggregation based on your strategy.

Trouble Shooting

If you can not publish JaCoCo reports correctly, please:

  1. Make sure you generate the Cobertura XML files.