Nick Palmer Nick Palmer - 22 days ago 10
Android Question

Running gradle's connectedAndroidTest on a specific device

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.

Answer

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 to connectedAndroidTest for these sorts of on-device non-UI-automated tests, explicitly states:

Runs checks that requires a connected device or emulator. They will run on all connected devices in parallel.

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