This documentation relates to QuickBuild 5.0.x
Select here if you are using a different version

Publish JaCoCo Report

Version 5 by Steve Luo
on Jan 21, 2013 11:02.


compared with
Current by Steve Luo
on Jan 21, 2013 11:05.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 1 changes. View first change.

 To publish [JaCoCo|http://www.eclemma.org/jacoco/] report, you only need two steps:
 # Generate JaCoCo *XML* report from [Ant|http://ant.apache.org] or [Maven|http://maven.apache.org] or any other build tool.
 # Add JaCoCo publish step by choosing _Publish -> JaCoCo Report_ from step menu.
  
 {note:title=Note}
 The JaCoCo should be version 0.6.1 or higher.
 {note}
  
 h2. Generate JaCoCo Report
  
 QuickBuild will NOT generate [JaCoCo|http://www.eclemma.org/jacoco/] report automatically, so first make sure the [JaCoCo|http://www.eclemma.org/jacoco/] report is produced by [ANT|http://ant.apache.org] or by any other build tool. The following example shows how to generate JaCoCo coverage XML report with [Ant Cobertura task|http://cobertura.sourceforge.net/anttaskreference.html], you may find more examples from [JaCoCo|http://www.eclemma.org/jacoco/] website:
  
 {code:xml|title=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>
 {code}
 The code snippet will generate the JaCoCo report will be captured to '$\{result.report.dir\}/report.xml'.
 {note}
 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.
 {note}
  
 h2. 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|Publish Build Reports] for how to use report set.
  
 If the JaCoCo is published successfully, the build overview page will display the summary for your coverage,
  
 !jacoco-dashboard.png!
  
 and JaCoCo report tab will be displayed in your build page like below:
  
 !jacoco-report.png!
  
 below shows the coverage of source code opening from class report or method report:
  
 !jacoco-source.png!
  
 h2. Configure Coverage Threshold
  
 You may also change the JaCoCo coverage threshold for each configuration. Go to Configuration Settings / Report Settings / JaCoCo Setting:
  
 !jacoco-setting.png!
  
 then change to your threshold and configure the color you want.
  
  !jacoco-threshold.png!
  
  
 h2. 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.
  
  
 h2. Trouble Shooting
 If you can not publish JaCoCo reports correctly, please:
 # Make sure you generate the Cobertura XML files.