View Source

To publish [Cobertura|http://cobertura.sourceforge.net/index.html] report, you only need two steps:
# Generate Cobertura *XML* report from [Ant|http://ant.apache.org] or [Maven|http://maven.apache.org] or any other build tool.
# Add Cobertura publish step by choosing _Publish -> Cobertura Report_ from step menu.

{note:title=Note}
The cobertura should be version 1.9.2 or higher.
{note}

h2. Generate Cobertura Report

QuickBuild will NOT generate [Cobertura|http://cobertura.sourceforge.net/index.html] report automatically, so first make sure the [Cobertura|http://cobertura.sourceforge.net/index.html] report is produced by [ANT|http://ant.apache.org] or by any other build tool. The following example shows how to generate Cobertura test results with [Ant Cobertura task|http://cobertura.sourceforge.net/anttaskreference.html]:
{code:xml|title=Cobertura coverage report target in build.xml}
<target name="instrument" depends="jar">
<delete file="${basedir}/cobertura.ser" />
<delete file="${build.dir}/cobertura.ser" />

<cobertura-taskdef />

<cobertura-instrument datafile="${build.dir}/cobertura.ser" todir="${build.instrumented.dir}">
<fileset dir="${build.classes.dir}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
<exclude name="net/sourceforge/cobertura/javancss/*.class" />
</fileset>
<fileset dir="${build.otherclasses.dir}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
</target>

<target name="coverage-report">
<cobertura-taskdef />

<delete dir="${build.reports.dir}/coverage-xml" />
<mkdir dir="${build.reports.dir}/coverage-xml" />
<cobertura-report datafile="${build.dir}/cobertura.ser"
destdir="${build.reports.dir}/coverage-xml"
format="xml"
>
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${othersrc.dir}">
<include name="**/*.java" />
</fileset>
</cobertura-report>

<cobertura-check datafile="${build.dir}/cobertura.ser"
totalbranchrate="50"
totallinerate="50" />
</target>
{code}
The code snippet will generate the XML reports for each test case, and the reports will be captured to '$\{build.reports.dir\}/coverage-xml' directory.
{note}
For property src.dir, should define like below:
src.dir=$\{basedir}/src
instead of a relative path below:
src.dir=src

otherwise, opening source code from QuickBuild may fail if basedir is different from workspace directory.
{note}

h2. Publish Cobertura Report
Add _*Publish Cobertura Report*_ step to your build workflow. If you have several report sets, you can add several steps with different report set names. Reference [this page|Publish Build Reports] for more details.

h2. Trouble Shooting
If you can not publish Cobertura reports correctly, please:
# Make sure you generate the Cobertura XML files. As by default, Cobertura only generate .ser file.
# Make sure your file pattern is specified correctly. For example, Cobertura maven goal will generate the Cobertura XML files to target/site/cobertura/coverage.xml and the pattern "\*\*/target/\*.xml" will not work, instead, you may need use pattern like "\*\*/target/site/cobertura/\*.xml".