根據此連接的步驟爲現有的robotium項目自動生成ant的build.xml文件:http://xiaomaozi.blog.51cto.com/925779/932284/html
根據此連接的步驟將android-junit-report.jar導入項目並根據連接上的內容操做:http://www.xuebuyuan.com/2148574.htmlandroid
http://www.tuicool.com/articles/Rzayie express
將以下代碼加入到build.xml文件中去:測試
<target name="fetch-test-report">fetch
<xpath input="${tested.project.dir}/AndroidManifest.xml"ui
expression="/manifest/instrumentation/@android :targetPackage" output="tested.package"/>spa
<echo>Downloading XML test report...</echo>.net
<mkdir dir="${reports.dir}"/>xml
<exec executable="${adb}" failonerror="true">htm
<arg line="${adb.device.arg}"/>
<arg value="pull" />
<arg value="/data/data/${tested.package}/files/junit-report.xml"/>
<arg value="${reports.dir}/junit-report.xml"/>
</exec>
</target>
"/manifest/instrumentation/@android :targetPackage"這裏要注意指的是應該指向測試項目中AndroidManifest.xml中的instrumentation的package,否則會報錯。
<instrumentation
android:name="com.zutubi.android.junitreport.JUnitReportTestRunner"
android:targetPackage="com.example.example"/>
還要在ant.property中添加
test.runner=com.zutubi.android.junitreport.JUnitReportTestRunner