首页 > 其他 > 详细

uiautomator2.0框架

时间:2017-05-25 12:35:18      阅读:1093      评论:0      收藏: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:\eclipse2\workspace\test-miui\bin\uitestpowerconsume.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&

uiautomator2.0框架

原文:http://www.cnblogs.com/yyh8/p/6902942.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!