How do you run connectedAndroidTest
on a particular device?
I would expect something like:
./gradlew connectedAndroidTest -DconnectedAndroidTest.device=XXXX
We have a number of devices plugged into our CI server and I can't seem to find any documentation on how to target a specific connected device.
connectedAndroidTest
runs the tests on ALL connected devices currently.
Thanks.
Use the
ANDROID_SERIAL
variableYou can do this two ways:
1. Set environment variable
2. "Set" for just a command
If you set/exported ANDROID_SERIAL (method #1), you can use this to override that for a single command.
Note
This works with emulator identifiers (e.g., "emulator-5554"), too.
It should be possible now. Just set
ANDROID_SERIAL
environment variable to the device id you want your tests to run on.It's not supported. The documentation for
connectedCheck
at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Android-tasks, which delegates toconnectedAndroidTest
for these sorts of on-device non-UI-automated tests, explicitly states:There is a feature request for the ability to select individual devices; you can track its progress at https://code.google.com/p/android/issues/detail?id=66129
I created an "hack" to be able to do it.. put this block in the
android
section of your build.gradle, and then you have to set theANDROID_HOME
env variable to the sdk folder, and theUNIT_TESTS_DEVICE_ID
env variable with the serial number of the device on which you want to run tests on.Then you use the task
singleDeviceAndroidTest{Variant}
to run the tests. Tested only on gradle plugin version 1.0.0.