View Source

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

h2. Generate EMMA Report

QuickBuild will NOT generate [EMMA|http://emma.sourceforge.net] report automatically, so first make sure that the EMMA report is produced by [ANT|http://ant.apache.org] or by any other build tool. The following example shows how to generate EMMA [code coverage|Concepts#code coverage] with [Ant EMMA task|http://emma.sourceforge.net/reference/ch02s02s02.html]:
{code:xml|title=EMMA target in build.xml}
<target name="emma.instr" depends="clean, compile.tests" if="emma.enabled">
<available file="lib/emma.jar" property="emma.available"/>
<fail unless="emma.available" message="Error: emma.jar not found" />
<path id="emma.lib.dir">
<pathelement location="${lib.dir}/emma.jar" />
<pathelement location="${lib.dir}/emma_ant.jar" />
</path>

<taskdef resource="emma_ant.properties" classpathref="emma.lib.dir" />
<mkdir dir="${emma.report.dir}" />
<emma>
<instr instrpath="${build.home}/classes"
destdir="${build.home}/classes"
metadatafile="${emma.report.dir}/metadata.emma"
merge="true" mode="overwrite" />
</emma>
</target>

<!-- Run all the JUnit Tests -->
<target name="junit" depends="emma.instr">
<mkdir dir="${junit.report.dir}" />
<mkdir dir="${junit.report.dir}/test-out" />
<record name="${junit.report.dir}/test-output.txt" append="no" action="start"/>
<junit printsummary="yes" haltonfailure="false" fork="yes">
<jvmarg value="-Demma.coverage.out.file=${emma.report.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />

<classpath refid="test.classpath"/>
<!-- <formatter type="plain"/> -->
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.report.dir}/test-out">
<fileset dir="${test.home}">
<include name="**/*Test.java"/>
<exclude name="**/*AbstractTest.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.report.dir}">
<fileset dir="${junit.report.dir}/test-out">
<include name="TEST-*.xml"/>
</fileset>
</junitreport>
<record name="${junit.report.dir}/test-output.txt" action="stop"/>
</target>

<!-- Generate Emma Report -->
<target name="emma.report" depends="junit" if="emma.enabled">
<emma enabled="true">
<report sourcepath="${dir.src}"
sort="+name,+class,+method,+block"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${emma.report.dir}">
<include name="*.emma" />
</fileset>
<xml outfile="${emma.report.dir}/coverage.xml" depth="method" />
</report>
</emma>

<!-- deleted the instrumented .class files -->
<!-- <delete dir="${build.home}/classes" /> -->
</target>
{code}
The code snippet will generate the XML report for all the source code. XML report coverage.xml will be generated in 'reports/emma directory' directory which is relative to the [workspace|Concepts#workspace] directory.

After adding the target above, generate the XML code coverage report for your source code, and after that you can tell QuickBuild to publish the results.

h2. Publish EMMA Report

Just like all other [build reports|Publish Build Reports], you can add EMMA report by [adding a publish step|Working With Step] in a [configuration|Working with Configurations]. When you add publish EMMA Report step, the following screen will be displayed:

!Screenshots^report_publish_step.png!

In source files field, QuickBuild uses Ant style file patterns to collect the reports, and the directory you specified is *relative* to the [workspace|Configuration Workspace] directory.