標籤:shell from str 生產 common amp sts record 命名
1、JUnit的TestSuite可以集中存放測試類別,並批量運行測試類別中的測試案例,源碼如下:
package com.coolwi.km.user.testsuites;
import com.coolwi.km.user.testcase.MyCardRecord;
import com.coolwi.km.user.testcase.MyCardUserTestcase1;
import junit.framework.JUnit4TestAdapter;
import junit.framework.Test;
import junit.framework.TestSuite;
//import junit.sampling.*;
public class TestAll {
public static Test suite()
{
TestSuite suite = new TestSuite("All tests from part1");//表明這個標識性東西
suite.addTestSuite(MyCardRecord.class);
suite.addTestSuite(MyCardUserTestcase1.class);
//suite.addTest(new TTmmTest("testHelloworld"));//這裡可以添加單個的測試方法
return suite;
}
}
舉個栗子:可以建立testsuites來存放所有的testsuit,在這個包下建立一個LoginSuit,然後編寫Login_1、Login_2、Login_3,便可運行登入的測試案例
2、選擇使用Android Junit Test 運行 TestAll ,便可批量運行選中的所有測試案例
3、生產JUnit 格式的report
a、匯入(一)中的jar包
b、在runner包下建立一個Runner,命名為CommonRunner,讓該Runner繼承JUnitReportTestRunner,在AndroidManifest.xml中聲明該Runner
<instrumentation
// android:name="com.zutubi.android.junitreport.JUnitReportTestRunner"
android:name="com.coolwi.km.user.runner.CommonRunner"
android:targetPackage="com.coolwi.km.user" />
c、更新第一步的類為TestAll1,繼承 CommonRunner,運行TestAll1
4、匯出測試案例
adb pull /data/data/com.xxx.xxx/files/junit-report.xml
a、adb shell 進入手機,並cd (確保手機被root)
b、su 切換到 root身份
c、用rm -f junit-report.xml確保手機內沒有該檔案,然後運行指令碼
PS:可能運行指令碼後沒有查看到報告,原因是該檔案夾沒有寫的許可權,此時需要 chmod該檔案夾,再運行指令碼
cd /data
chmod -R 777 /data
cd /data/data
chmod -R 777 /data/data
安卓自動化測試:Robotium(三)批量運行測試代碼