qileilove

blog已经转移至github,大家请访问 http://qaseven.github.io/

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.运行所有的测试用例
  举个栗子:运行测试工程下的所有用例
  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();
}
}

posted on 2014-04-25 09:55 顺其自然EVO 阅读(2102) 评论(0)  编辑  收藏 所属分类: selenium and watir webdrivers 自动化测试学习android


只有注册用户登录后才能发表评论。


网站导航:
 
<2014年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

统计

常用链接

留言簿(55)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜