zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    linux command lynx
    git bisect
    git blame (10)
    git crate&query&delete tag(九)
    git crate patch and check&apply patch(八)
    learning shell check host dependent pkg (8)
    【泛型】
    sql server 查询所有表的记录数
    【转】EXCEL中如何实现由总表自动得出分表
    MS Chart 打印
  • 原文地址:https://www.cnblogs.com/riskyer/p/3359826.html
Copyright © 2011-2022 走看看