使用AndroidStudio执行UI Automator 自动化测试版本问题

摘要

最近在研究UiAutomator自动化测试问题,写好之后却报了下面这样一个问题:


网上看到UIAutomator 2.0版本,并且貌似使用的框架都改变了,所以今天就抽空试了下

We’re pleased to announce the release of UIAutomator 2.0! This version is a significant update from the previous release. Most importantly, UI Automator is now based on Android Instrumentation and you can build and run tests with the ‘./gradlew connectedCheck’ command.

大体的意思就是UIAutomator2.0基于的框架改成了android的instrumentatioin的框架。并且可以通过gradle进行配置了,虽然说实话不太清楚为什么要将UiAutomator的框架改成instrumentation,但是我们先试试大概答题的环境出来吧。

下来我们就来试试通过Android Studio 来进行UiAutomator的配置吧

UiAutomator2.0的jar包并不是在以前SDK/platforms/android-19/下。现在我们要这么做

  1. 通过Android SDK Manager中的 Android Support Repository 项进行安装
  2. 下载下来的jar包的路径为/extras/android/m2repository
  3. 新建一个android项目,编写一个简单的应用
  4. 在build.gradle中配置依赖项:

    dependencies {
      androidTestCompile 'com.android.support.test:runner:0.3'
      // Set this dependency to use JUnit 4 rules
      androidTestCompile 'com.android.support.test:rules:0.3'
      // Set this dependency to build and run Espresso tests
      androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
      // Set this dependency to build and run UI Automator tests
      androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    }

    设置AndroidJunitRunner为默认的testInstrumentationRunner

    android {
        defaultConfig {
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
  5. }
  6. 以上版本问题是解决了,但是jar包的问题还被困扰,有路过的大神望指导一下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值