使用Robotium进行测试的时候,要想可以导出可视的测试结果,可以使用junitreport来实现
junitreport下载地址:
https://github.com/jsankey/android-junit-report
我们按照之前使用Robotium的编写测试步骤来执行,重复的这里不再赘述。
1. 将junitreport添加到工程的libs目录中
2. 将junitreport-xxxx.jar添加到build_path中(右键此文件,Build Path->add to build path
3. 修改测试工程中AndroidManifest.xml文件,如后面xml修改处下
4. 修改工程Run Configure中,Instrumentation Runner为一下修改的android:name
5. 运行之后,测试报告生成在被测文件根目录files中。如com.example.aa/files/junit-report.xml
AndroidManifest.xml文件修改之处
<
instrumentation
android:name
="com.zutubi.android.junitreport.JUnitReportTestRunner"
//修改此处为这个样子
android:targetPackage
="com.ziipin.ship.ui"
/>
测试报告导出:
adb pull /data/data/com.example.aa/files/junit-report.xml e:/
报告文件类似于:
<?
xml version='1.0' encoding='utf-8' standalone='yes'
?>
<
testsuites
>
<
testsuite
name
="com.testshipping.TestShipping"
>
<
testcase
classname
="com.testshipping.TestShipping"
name
="testLogin"
time
="19.986"
/>
<
testcase
classname
="com.testshipping.TestShipping"
name
="testMyOrder"
time
="35.089"
/>
<
testcase
classname
="com.testshipping.TestShipping"
name
="testOrderDoubleTicket"
time
="43.041"
/>

