Astrid unit tests: use zutubi junit xml reporter to generate junit xml. also use emma xml reporter to generate emma xml

pull/14/head
Tim Su 15 years ago
parent 968ccc9fe4
commit db6d11539e

@ -4,5 +4,6 @@
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry combineaccessrules="false" kind="src" path="/astrid"/> <classpathentry combineaccessrules="false" kind="src" path="/astrid"/>
<classpathentry kind="lib" path="libs/android-junit-report-1.0.3.jar"/>
<classpathentry kind="output" path="ecbuild"/> <classpathentry kind="output" path="ecbuild"/>
</classpath> </classpath>

1
tests/.gitignore vendored

@ -2,3 +2,4 @@ bin/
instrumented/ instrumented/
coverage.em coverage.em
coverage/ coverage/
reports/

@ -19,7 +19,7 @@
the package of the parent app. To run the tests use the command: the package of the parent app. To run the tests use the command:
"adb shell am instrument -w com.xxx.xxx.tests/android.test.InstrumentationTestRunner" "adb shell am instrument -w com.xxx.xxx.tests/android.test.InstrumentationTestRunner"
--> -->
<instrumentation android:name="android.test.InstrumentationTestRunner" <instrumentation android:name="com.zutubi.android.junitreport.JUnitReportTestRunner"
android:targetPackage="com.timsu.astrid" android:targetPackage="com.timsu.astrid"
android:label="Tests for Astrid"/> android:label="Tests for Astrid"/>
</manifest> </manifest>

@ -24,3 +24,8 @@ out.dir=bin
# because we pull in from multiple source folders # because we pull in from multiple source folders
source.dir=${out.dir}/source source.dir=${out.dir}/source
# test runner: junit report test runner
test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner
# reports output directory
reports.dir=reports

@ -64,7 +64,14 @@
--> -->
<setup /> <setup />
<target name="coverage"> <target name="coverage" depends="-prepare-coverage-source">
<antcall target="android-coverage">
<param name="source.dir" value="bin/source" />
</antcall>
<antcall target="pull-junit" />
</target>
<target name="-prepare-coverage-source">
<subant target="help"> <subant target="help">
<fileset file="${tested.project.absolute.dir}/build.xml" /> <fileset file="${tested.project.absolute.dir}/build.xml" />
</subant> </subant>
@ -77,9 +84,59 @@
<copy todir="${source.dir}"> <copy todir="${source.dir}">
<fileset dir="src" /> <fileset dir="src" />
</copy> </copy>
<antcall target="android_test_rules.coverage">
<param name="source.dir" value="bin/source" />
</antcall>
</target> </target>
<target name="pull-junit">
<exec executable="${adb}" failonerror="true">
<arg line="${adb.device.arg}"/>
<arg value="pull" />
<arg value="/data/data/${tested.manifest.package}/files/junit-report.xml" />
<arg value="${reports.dir}/junit-report.xml" />
</exec>
</target>
<!-- clone of android coverage target with extra purposes:
1. generate emma xml report
2. use adb device arg to pull coverage file
-->
<target name="android-coverage" 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>
<mkdir dir="${reports.dir}" />
<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 -->
<html outfile="${reports.dir}/coverage.html" />
<xml outfile="${reports.dir}/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.html</echo>
</target>
</project> </project>

Loading…
Cancel
Save