zoukankan      html  css  js  c++  java
  • uiautomator2.0框架

    1.

     

    Uiautomator1.0

    Uiautomator2.0

    date

    2012

    2015

    super class

    UiAutomatorTestCase

    InstrumentationTestCase

    language

    java

    java

    executable file

    jar

    APK

    API-level

    16(4.1)+

    18(4.3)+

    permission

    -

    less

    context

    no

    yes

    extends

    Junit3 需要继承UiAutomatorTestCase

    Junit4 测试类不需要继承父类

    2.

    Linux 下Set up UI Automator2.0

    打开android studio,新建工程  File—》new—》new project,选择最小的sdk为19,选择【Blank Activity】,下一步-完成;

    3.

    修改build.gradle(Module:app)文件

    android{}中增加

    packagingOptions {

            exclude 'LICENSE.txt'

    }

    defaultConfig {

            multiDexEnabled true

    }

    dependencies{}中增加

    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'

    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'     /v18:2.1.1

    4.

    app-java-..[AndroidTest]中创建类,编写脚本,点击un 运行脚本

                                                              

    5.

    脱机运行:

    uiautomator1.0

    .adb push E:eclipse2workspace est-miuiinuitestpowerconsume.jar /data/local/tmp

    adb shell uiautomator runtest uitestpowerconsume.jar --nohup -c com.miui.sec.Test_PowerConsume#testPowerConsume

    Uiautomator2.0:

    方法1.

    使用这个nohup  这个参数时,会报错是: nohup: /nohup.out: Read-only file system

    所以我使用重新写了个路径    eg: /data/nohup.out

    但是是先进到shell中  再执行

    nohup am instrument -w -r -e debug false -e class com.demo.mi.myapplication.Demo com.demo.mi.myapplication.test/android.support.test.runner.AndroidJUnitRunner > /data/nohup.out

    方法2.

    在末尾加上&  也可以实现

    先进到shell中  再执行

    nohup am instrument -w -r -e debug false -e class com.demo.mi.myapplication.Demo com.demo.mi.myapplication.test/android.support.test.runner.AndroidJUnitRunner&

    UIAUTOMATOR 2.0的教程http://blog.csdn.net/java18/article/details/53535928

  • 相关阅读:
    软件工程结课作业
    十三次作业
    十二次作业
    十一次作业
    十次作业
    找回感觉的练习
    CSS背景样式和列表样式
    盒子模型案例应用
    display属性
    margin外边距属性
  • 原文地址:https://www.cnblogs.com/yyh8/p/6902942.html
Copyright © 2011-2022 走看看