Robotium测试用例执行顺序及批处理方式

Chynna ·
更新时间:2024-09-20
· 561 次阅读

  一、控制测试用例的执行顺序   采用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.运行所有的测试用例   举个栗子:运行测试工程下的所有用例   1adb shell am instrument -w com.taobao.taobao.test/android.test.InstrumentationTestRunner   2.运行单个测试类或某个TestSuite   举个栗子:运行测试类com.taobao.taobao.test.TestRegister   1adb 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 1adb shell am instrument -e class com.taobao.taobao.test.TestLogin,com.taobao.taobao.test.TestRegister#testRegister  -w com.taobao.taobao.test/android.test.InstrumentationTestRunner 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(); } }



robotium 批处理

需要 登录 后方可回复, 如果你还没有账号请 注册新账号