Quantcast
Viewing all articles
Browse latest Browse all 11

Android JUnit XML Reports: Multiple File Support

Due to popular demand, I’ve added support for multiple output files (one per test suite) to android-junit-report.

For simplicity and efficiency, android-junit-report does not produce files in the exact format used by the Ant JUnit task. In the 1.1 release there are two main differences:

  1. A single report file is produced containing all test suites.
  2. Redundant information, such as the number of cases, failures etc is not added using attributes on the testsuite tag.

It turns out the first of these restrictions caused multiple users issues with tools accustomed to handling a single report file per suite. So in the latest 1.2 release I have added a new multiFile option. When this option is enabled, android-junit-report produces a separate output file for each test suite. This does mean that to retrieve the results from the device you will need to pull a whole directory.

To enable this option from an Ant build, you can override the default run-tests target as follows:

<target name="run-tests" depends="-install-tested-project, install"
       description="Runs tests from the package defined in test.package property">
    <property name="reports.dir" value="${out.dir}/reports"/>
    <property name="files.dir" value="/data/data/${tested.manifest.package}/files"/>
    <echo>Cleaning up previous test reports…</echo>
    <delete dir="${reports.dir}"/>
    <exec executable="${adb}" failonerror="true">
        <arg line="${adb.device.arg}" />
        <arg value="shell" />
        <arg value="rm" />
        <arg value="${files.dir}/*" />
    </exec>
    <echo>Running tests…</echo>
    <exec executable="${adb}" failonerror="true">
        <arg line="${adb.device.arg}"/>
        <arg value="shell" />
        <arg value="am" />
        <arg value="instrument" />
        <arg value="-w" />
        <arg value="-e" />
        <arg value="coverage" />
        <arg value="@{emma.enabled}" />
        <arg value="-e" />
        <arg value="multiFile" />
        <arg value="true" />
        <arg value="${manifest.package}/${test.runner}" />
    </exec>      
    <echo>Downloading XML test reports…</echo>
    <mkdir dir="${reports.dir}"/>
    <exec executable="${adb}" failonerror="true">
        <arg line="${adb.device.arg}"/>
        <arg value="pull" />
        <arg value="${files.dir}" />
        <arg value="${reports.dir}" />
    </exec>
</target>

You can learn more about android-junit-report and/or download the new release using the links below:


Viewing all articles
Browse latest Browse all 11

Trending Articles