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.
To run a test from the command line, run adb shell to start a command line shell on your device or emulator. Inside that shell you can interact with the activity manager using the am command and use its instrument subcommand to run your tests.
You can do gradle -Dtest. single=ClassUnderTestTest test if you want to test single class or use regexp like gradle -Dtest. single=ClassName*Test test you can find more examples of filtering classes for tests under this link.
assembleAndroidTest is the gradle command to build the second test apk. By default assembleAndroidTest will build the test apk with the debug build type. You can change the build type by adding this to your build.
ANDROID_SERIAL
variableYou can do this two ways:
# Set once; all following gradlew commands will use this export ANDROID_SERIAL=1000AB0123456YZ ./gradlew <...>
ANDROID_SERIAL=1000AB0123456YZ ./gradlew <...>
If you set/exported ANDROID_SERIAL (method #1), you can use this to override that for a single command.
This works with emulator identifiers (e.g., "emulator-5554"), too.
It was not supported in 2014. 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 (now marked as fixed) for the ability to select individual devices: https://code.google.com/p/android/issues/detail?id=66129
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With