Robotium学习笔记二

一、 控制测试用例的执行顺序
采用TestSuit方式来控制每条Case的运行顺序
Demo如下
public static Test suite() {
TestSuite suite = new TestSuite();
//$JUnit-BEGIN$
suite.addTestSuite(CopyOfTestApk.class);
//$JUnit-END$
return suite;
}
二、 bat批处理方式启动Robotium脚本
单个启动
am instrument -w com.testcalculator/android.test.InstrumentationTestRunner
启动Test Suit
Am instrument -e class com.testcalculator.AllTests -w com.testcalculator/android.test.InstrumentationTestRunner
Java中启动
public  void callChosenTest(){

Runtime run = Runtime.getRuntime();
try {
//Process p = run.exec("am instrument -w com.testcalculator/android.test.InstrumentationTestRunner");///执行全部的测试案例
Process p = run.exec("am instrument -e class com.testcalculator.AllTests -w com.testcalculator/android.test.InstrumentationTestRunner");
//执行一个测试案例
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}


命令行启动
1.运行所有的测试用例
举个栗子:运行测试工程下的所有用例
1 adb shell am instrument -w com.taobao.taobao.test/android.test.InstrumentationTestRunner
 
2.运行单个测试类或某个TestSuite
举个栗子:运行测试类com.taobao.taobao.test.TestRegister 


1 adb shell am instrument -e class com.taobao.taobao.test.TestRegister -w com.taobao.taobao.test/android.test.InstrumentationTestRunner
 
3.运行某个测试类里面的某个测试方法
举个栗子:运行com.taobao.taobao.test.TestRegister中的测试方法testRegister
adb shell am instrument -e class com.taobao.taobao.test.TestRegister#testRegister -w com.taobao.taobao.test/android.test.InstrumentationTestRunner 
4.运行两个不同的测试类或类中的方法
举个栗子:运行com.taobao.taobao.test.TestLogin
和com.taobao.taobao.test.TestRegister类中的方法testRegister
1 adb shell am instrument -e class com.taobao.taobao.test.TestLogin,com.taobao.taobao.test.TestRegister#testRegister  -w com.taobao.taobao.test/android.test.InstrumentationTestRunner

posted on 2013-10-09 18:36  you Richer  阅读(248)  评论(0编辑  收藏  举报