Integrate EMMA (full) Code Coverage Report into TeamCity

First things first: I try to use EMMA offline via instrumentation and integrate the coverage data into TeamCity so that I can see a full report, and especially the diff-information and statistics (graphs) between runs.

My TeamCity-Setup:

* Maven project creating and deploying an .ear file with classes instrumented via maven-emma-plugin from codehaus (emma-2.1.5320) into jBoss-5.1.0.GA. The metadata file of emma is written to ${svn.root}/coverage.em
* Start-up the jboss via script and with emma-property set: -Demma.coverage.out.file=${SVN_ROOT}/coverage.ec
* Start Selenium tests via maven, which test the application on the jboss
* Stop the jboss (JVM exit, EMMA writes the coverage info)
* Run ANT-Script with EMMA-coverage enabled with the following content:

<?xml version="1.0"?>
<project name="EMMA (offline mode)" default="emma" basedir=".." >
  <!-- output directory used for EMMA coverage reports: -->
  <property name="coverage.dir" value="${basedir}/coverage" />
  <!-- directory that contains emma.jar and emma_ant.jar: -->
  <property name="emma.dir" value="${basedir}/lib" />
  <!-- path element used by EMMA taskdef below: -->
  <path id="emma.lib" >
    <pathelement location="${emma.dir}/emma.jar" />
    <pathelement location="${emma.dir}/emma_ant.jar" />
  </path>
  <!-- this loads <emma> and <emmajava> custom tasks: -->
  <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
  <target name="emma" description="runs the instrumentation" >
    <emma enabled="true" >
        <report
              sort="+block,+name,+method,+class"
              metrics="method:70,block:80,line:80,class:100" >
        <infileset dir="${coverage.dir}" includes="*.em, *.ec" />

        

    <sourcepath>
      <dirset dir="${basedir}" >
        <include name="**/src/main/java" /> 
      </dirset>
    </sourcepath>

        <txt outfile="${basedir}/coverage.txt"
             depth="package"
             columns="class,method,block,line,name" />
        <xml outfile="${basedir}/coverage.xml"
             depth="package" />
        <html outfile="${basedir}/coverage.html"
             depth="method"
             columns="name,class,method,block,line" />
        </report>
    </emma>
  </target>

</project>

So, my problem is, that the report Overview exists, but I cannot see a full report (there is no link "view full report"). And the build log says:

[15:57:20]:     [Step 8/8] Starting: /usr/lib/jvm/java-6-sun-1.6.0.24/jre/bin/java -Dagent.home.dir=/var/lib/teamcity/TeamCity/buildAgent -Dagent.name=Default Agent -Dagent.ownPort=9090 -Dagent.work.dir=/var/lib/teamcity/TeamCity/buildAgent/work -Dant.home=/var/lib/teamcity/TeamCity/buildAgent/plugins/ant -Dbuild.number=45 -Dbuild.vcs.number=7495 -Dbuild.vcs.number.1=7495 -Dbuild.vcs.number.MYAPP_1_4_Branch=7495 -Demma.disable.source=false -Demma.instrumentation.parameters= -Dfile.encoding=UTF-8 -Dfile.separator=/ -Djava.io.tmpdir=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp -Dos.arch=amd64 -Dos.name=Linux -Dos.version=2.6.32-32-server -Dpath.separator=: -Dreport.html.out.encoding=UTF-8 -Dreport.html.out.file=coverage/index.html -Dteamcity.agent.cpuBenchmark=347 -Dteamcity.agent.dotnet.agent_url=http://localhost:9090/RPC2 -Dteamcity.agent.dotnet.build_id=287 -Dteamcity.auth.password=qgbmVto9Lf9LuQzGP5qn1ppyoMYh2TAv -Dteamcity.auth.userId=TeamCityBuildId=287 -Dteamcity.build.changedFiles.file=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp/changedFiles6153790662641190900.txt -Dteamcity.build.checkoutDir=/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd -Dteamcity.build.id=287 -Dteamcity.build.properties.file=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp/teamcity.build1381653269404977291.properties -Dteamcity.build.tempDir=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp -Dteamcity.build.workingDir=/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd -Dteamcity.buildConfName=Selenium-Tests-1.4-Branch -Dteamcity.buildType.id=bt8 -Dteamcity.configuration.properties.file=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp/teamcity.config1441934221516540162.properties -Dteamcity.coverage.runner=EMMA -Dteamcity.idea.home=/var/lib/teamcity/TeamCity/buildAgent/plugins/idea -Dteamcity.projectName=MYAPP -Dteamcity.runner.properties.file=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp/teamcity.runner2074016144816026698.properties -Dteamcity.runtime.props.file=/var/lib/teamcity/TeamCity/buildAgent/temp/agentTmp/ant7653392872077792725runtime -Dteamcity.tests.recentlyFailedTests.file=/var/lib/teamcity/TeamCity/buildAgent/temp/buildTmp/testsToRunFirst6912152142467488844.txt -Dteamcity.version=6.5.1 (build 17834) -Duser.country=DE -Duser.home=/var/lib/teamcity -Duser.language=de -Duser.name=teamcity -Duser.timezone=Europe/Berlin -classpath /var/lib/teamcity/TeamCity/buildAgent/plugins/ant/lib/ant-launcher.jar org.apache.tools.ant.launch.Launcher -lib /var/lib/teamcity/TeamCity/buildAgent/plugins/antPlugin/ant-runtime.jar:/var/lib/teamcity/TeamCity/buildAgent/lib/runtime-util.jar -listener jetbrains.buildServer.agent.ant.AgentBuildListener -buildfile /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/scripts/teamcity-emma-ant.xml
[15:57:20]:     [Step 8/8] in directory: /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd
[15:57:21]:     [Step 8/8] emma
[15:57:21]:         [emma] emma
[15:57:21]:             [emma] processing input files ...
[15:57:21]:             [emma] 2 file(s) read and merged in 140 ms
[15:57:21]:             [emma] writing [txt] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.txt] ...
[15:57:22]:             [emma] writing [xml] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.xml] ...
[15:57:22]:             [emma] writing [html] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage/coverage.html] ...
[15:57:26]:     [Step 8/8] EMMA: Create Report
[15:57:30]:         [EMMA: Create Report] Unable to find /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.em, cannot create EMMA report
[15:57:30]:     [Step 8/8] Process exited with code 0
[15:57:30]:     [Step 8/8] Publishing artifacts
[15:57:30]:         [Publishing artifacts] Paths to publish: [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.ec, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.em, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.txt, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage/coverage.zip]
[15:57:30]:         [Publishing artifacts] Artifacts path coverage.ec not found
[15:57:30]:         [Publishing artifacts] Artifacts path coverage.em not found
[15:57:30]:         [Publishing artifacts] Artifacts path coverage/coverage.zip not found
[15:57:30]:         [Publishing artifacts] Sending files
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageL' value='52.338528']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='15275.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='29185.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageB' value='52.588814']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='85633.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='162835.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageM' value='57.16946']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='3991.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='6981.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageC' value='70.07455']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsCCovered' value='658.0']
[15:57:30]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsCTotal' value='939.0']
[15:57:30]: Waiting for 82 service processes to complete
[15:57:30]: Publishing internal artifacts
[15:57:34]:     [Publishing internal artifacts] Sending build.finish.properties file


What am I doing wrong? Is my ant-file errenous?



Attachment(s):
emma_diff_no_full_report.png
2 comments
Comment actions Permalink

another problem is, that there seem to be more blocks than lines. The "columns" seem to have the wrong order so that these values are transposed. How can I fix this?

0
Comment actions Permalink

I have solved the first problem by now. The build log ends as follows:

[18:06:02]:     [Step 8/8] in directory: /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd
[18:06:03]:     [Step 8/8] emma
[18:06:03]:         [emma] emma
[18:06:04]:             [emma] processing input files ...
[18:06:04]:             [emma] 2 file(s) read and merged in 427 ms
[18:06:04]:             [emma] writing [txt] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.txt] ...
[18:06:06]:             [emma] writing [xml] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.xml] ...
[18:06:06]:             [emma] writing [html] report to [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage/index.html] ...
[18:06:09]:         [emma] copy
[18:06:09]:             [copy] Copying 2 files to /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd
[18:06:09]:     [Step 8/8] EMMA: Create Report
[18:06:09]:         [EMMA: Create Report] EMMA commandline: [-r, html,txt, -in, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.em,/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.ec, -Dreport.html.out.file=coverage/index.html, -Dreport.txt.out.file=/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.txt]
[18:06:13]:     [Step 8/8] Process exited with code 0
[18:06:13]:     [Step 8/8] Publishing artifacts
[18:06:13]:         [Publishing artifacts] Paths to publish: [/var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.ec, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.em, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage.txt, /var/lib/teamcity/TeamCity/buildAgent/work/ab00d08ad6056bcd/coverage/coverage.zip]
[18:06:13]:         [Publishing artifacts] Sending files
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageL' value='52.502995']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='15323.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='29185.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageB' value='52.718395']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='85844.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='162835.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageM' value='57.269733']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='3998.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='6981.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageC' value='70.07455']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsCCovered' value='658.0']
[18:06:13]:     [Step 8/8] ##teamcity[buildStatisticValue key='CodeCoverageAbsCTotal' value='939.0']
[18:06:13]: Waiting for 82 service processes to complete
[18:06:13]: Publishing internal artifacts
[18:06:14]:     [Publishing internal artifacts] Sending build.finish.properties file
[18:06:14]: Build finished


And I've got the full report (though its the emma report only, not teamcity-integrated one, but this seems to be intentional, right?).

I changed the following:
Index: scripts/teamcity-emma-ant.xml
===================================================================
--- scripts/teamcity-emma-ant.xml    (Revision 7497)
+++ scripts/teamcity-emma-ant.xml    (Arbeitskopie)
@@ -22,7 +22,7 @@
           </dirset>
         </sourcepath>
     <txt outfile="${basedir}/coverage.txt"
-             depth="package"
+             depth="method"
              columns="class,method,block,line,name" />
         <xml outfile="${basedir}/coverage.xml"
              depth="package" />
@@ -33,5 +33,11 @@
         />    
        </report>
     </emma>
+    <copy todir="${basedir}">
+      <fileset dir="${coverage.dir}">
+        <include name="coverage.em"/>
+        <include name="coverage.ec"/>
+      </fileset>
+    </copy>
   </target>
</project>


The second problem (block/line order) remains.

But the solution to copy the coverage files afterwards, because they are removed during the emma-task somehow, is a hack. So, is there any documentation on how the EMMA-tool of teamcity in combination with ANT works? It seems to retrieve the coverage.txt in order to show the overview and publish the generated html-report.

0

Please sign in to leave a comment.