zoukankan      html  css  js  c++  java
  • uiautomator 自定义testrunner使用和启动原理

    继承testrunner实现runner

    public class TestRunner extends UiAutomatorTestRunner
    {
        private final List<String> mTestClasses = new ArrayList<String>();
     
        @Override
        public void run(List<String> testClasses, Bundle params, boolean debug, boolean monkey)
        {
            try
            {
                testClasses.removeAll(testClasses);  //removeAll
                addTestClasses();
                testClasses.addAll(mTestClasses); //addAll
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            super.run(testClasses, params, debug, monkey);
    }

    运行testrunner

    -e runner com.meizu.browser.test.TestRunner

    应用

    可以根据外部传入的值,来确定需要执行什么用例

    例如-e priority p1  取出priority值,在addtestcase的时候只加入priority是P1的testcase

    获取runner源码

    /*     */   protected UiAutomatorTestRunner getRunner() {
    /* 140 */     if (this.mRunner != null) {
    /* 141 */       return this.mRunner;
    /*     */     }
    /*     */     
    /* 144 */     if (this.mRunnerClassName == null) {
    /* 145 */       this.mRunner = new UiAutomatorTestRunner();
    /* 146 */       return this.mRunner;
    /*     */     }
    /*     */     
    /* 149 */     Object o = null;
    /*     */     try {
    /* 151 */       Class<?> clazz = Class.forName(this.mRunnerClassName);
    /* 152 */       o = clazz.newInstance();
    /*     */     } catch (ClassNotFoundException cnfe) {
    /* 154 */       System.err.println("Cannot find runner: " + this.mRunnerClassName);
    /* 155 */       System.exit(-4);
    /*     */     } catch (InstantiationException ie) {
    /* 157 */       System.err.println("Cannot instantiate runner: " + this.mRunnerClassName);
    /* 158 */       System.exit(-4);
    /*     */     } catch (IllegalAccessException iae) {
    /* 160 */       System.err.println("Constructor of runner " + this.mRunnerClassName + " is not accessibile");
    /* 161 */       System.exit(-4);
    /*     */     }
    /*     */     try {
    /* 164 */       UiAutomatorTestRunner runner = (UiAutomatorTestRunner)o;
    /* 165 */       this.mRunner = runner;
    /* 166 */       return runner;
    /*     */     } catch (ClassCastException cce) {
    /* 168 */       System.err.println("Specified runner is not subclass of " + UiAutomatorTestRunner.class.getSimpleName());
    /*     */       
    /* 170 */       System.exit(-4);
    /*     */     }
    /*     */     
    /* 173 */     return null;
    /*     */   }
  • 相关阅读:
    mklink让网盘同步不同文件夹
    WINDOWS 的 MKLINK : 硬链接,符号链接 : 文件符号链接, 目录符号链接 : 目录联接
    Dropbox Folder Sync – 让 Dropbox 同步任意文件夹
    Tasker : Scale Up/Down CPU Speed at Different Times
    Tasker : Task / Shortcut Widgets
    Automate Screen or Button Taps via Tasker : Simulating keypress events
    Solution for sending Whatsapp via sqlite "INSERT INTO"
    SQL Server复制出错文章集锦
    SQL Server 2016 CTP2.2 的关键特性
    SQL Server表分区的NULL值问题
  • 原文地址:https://www.cnblogs.com/season-xie/p/6337682.html
Copyright © 2011-2022 走看看