wmbest.com
  • Home
  • About
Follow

Monthly archives for April, 2011

Android Coverage and Hudson/Jenkins

Apr18
2011
Leave a Comment Written by Bill

Recently we set up a Hudson continuous integration server at work. We are developing android apps and when I found out that Hudson had an Emma plugin I got excited. I found out about emma and android’s coverage reports. There was however one problem. Android’s <code>ant coverage</code> build will only output an html report. The hudson plugin requires an xml report.

To fix this I created a new build action in my build.xml. This is actually word for word what is in the coverage target with one minor change.

<target name="coverage-xml" depends="-set-coverage-classpath, -install-instrumented, install" description="Runs the tests against the instrumented code and generates code coverage report">
        <run-tests-helper emma.enabled="true">
        <extra-instrument-args>
            <arg value="-e" />
            <arg value="coverageFile" />
            <arg value="${emma.dump.file}" />
        </extra-instrument-args>
        </run-tests-helper>
        <echo>Downloading coverage file into project directory...</echo>
        <exec executable="${adb}" failonerror="true">
            <arg line="${adb.device.arg}" />
            <arg value="pull" />
            <arg value="${emma.dump.file}" />
            <arg value="coverage.ec" />
        </exec>
        <echo>Extracting coverage report...</echo>
        <emma>
            <report sourcepath="${tested.project.absolute.dir}/${source.dir}" verbosity="${verbosity}">
                <!-- TODO: report.dir or something like should be introduced if necessary -->
                <infileset dir=".">
                    <include name="coverage.ec" />
                    <include name="coverage.em" />
                </infileset>
                <!-- TODO: reports in other, indicated by user formats -->
                <xml outfile="coverage.xml" />
            </report>
        </emma>
        <echo>Cleaning up temporary files...</echo>
        <delete dir="${instrumentation.absolute.dir}" />
        <delete file="coverage.ec" />
        <delete file="coverage.em" />
        <echo>Saving the report file in ${basedir}/coverage/coverage.xml</echo>
    </target>

Here you can see the only real change to the target is this line:

<xml outfile="coverage.xml" />

as opposed to this

<html outfile="coverage.html" />

. Now we can output our coverage report to our workspace and feed it to the Hudson Emma plugin.

Posted in Uncategorized

Recent Posts

  • Android Coverage and Hudson/Jenkins
  • Business Objects 3.1 and Active Directory 2008 R2
  • Site downtime
  • Pythons and Pandas
  • Wmbest.com and future development

Recent Comments

Calendar

April 2011
M T W T F S S
« Sep    
 123
45678910
11121314151617
18192021222324
252627282930  

Tags

Android Blender c++ crash bandicoot general News panda Programming Python web

Archives

  • April 2011
  • September 2010
  • April 2010

Meta

  • Log in

EvoLve theme by Theme4Press  •  Powered by WordPress wmbest.com