working with UIautomator 2.0 and Android Studio 2.x

孤者浪人 提交于 2019-12-12 02:43:04

问题


I was working with uiautomator 1.0.1 using eclispe and generating jar files and using in my setup. Can anyone point to appropriate source where I can get step by step procedure for switching to Uiautomator 2.0 with Android Studio.


回答1:


To use the Android Testing Support Library in your Gradle project, add these dependencies in your build.gradle file:

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

Also you need to set the JUnitRunner as the default test instrumentation runner in your Gradle project (UI Automator 2.0 uses android.support.test.runner.AndroidJUnitRunner instead of android.test.InstrumentationTestRunner).

android {
    defaultConfig {
       testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

For more details, follow the link here.



来源:https://stackoverflow.com/questions/39501931/working-with-uiautomator-2-0-and-android-studio-2-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!