简体   繁体   中英

Running UiAutomator tests without Android Studio run option

I have built some tests on Android Studio using Uiautomator, but I dont want to run them on Android Studio (could be .jar file or .apk that can be run in any android device). The problem is those tests will not run in a user app, but in Android OS (example: performing a call to 123456 and ending the call)

How can I do it? The apk it generates doesnt work (force close) and it seems Android doesnt run .jar files (I need a NO ROOT solution.. can some1 help ke out? This have been killing me for long time.. Thank you!!

You can create the test APK

$ ./gradlew assembleAndroidTest

Then you can install the APK on a device and run the tests using adb

$ adb shell am instrument -w -r -e debug false -e class com.example.app.MyTest com.example.app.test/android.support.test.runner.AndroidJUnitRunner

so you will only need adb on the machine used to run the tests, which if it's Ubuntu/Debian you can install just by

$ sudo apt-get install android-tools-adb

I have built some tests on Android Studio using Uiautomator, but I dont want to run them on Android Studio

All instrumentation tests, including UiAutomator tests, must be run from a development machine. You do not have to use Android Studio — for example, you can run instrumentation tests from the command line with Gradle. But they have to be run from a development machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM