Instrumentation for Android and AWS Device Farm - AWS Device Farm

Instrumentation for Android and AWS Device Farm

Device Farm provides support for Instrumentation (JUnit, Espresso, Robotium, or any Instrumentation-based tests) for Android.

Device Farm also provides a sample Android application and links to working tests in three Android automation frameworks, including Instrumentation (Espresso). The Device Farm sample app for Android is available for download on GitHub.

For more information about testing in Device Farm, see Test frameworks and built-in tests in AWS Device Farm.

What is instrumentation?

Android instrumentation makes it possible for you to invoke callback methods in your test code so you can run through the lifecycle of a component step by step, as if you were debugging the component. For more information, see Instrumented tests in the Test types and locations section of the Android Developer Tools documentation.

Considerations for Android instrumentation tests

When using Android instrumentation, consider the following recommendations and notes.

Check Android OS Compatibility

Check the Android documentation , to ensure Instrumentation is compatible with your Android OS version.

Running from the Command Line

To run Instrumentation tests from the command line, please follow the Android documentation.

System Animations

Per the Android documentation for Espresso testing, it is recommended that system animations are turned off when testing on real devices. Device Farm automatically disables Window Animation Scale, Transition Animation Scale, and Animator Duration Scale settings when it executes with the android.support.test.runner.AndroidJUnitRunner instrumentation test runner.

Test Recorders

Device Farm supports frameworks, such as Robotium, that have record-and-playback scripting tools.

Standard mode test parsing

In the standard mode of a run, Device Farm parses your test suite and identifies the unique test classes and methods that it will run. This is done through a tool called Dex Test Parser.

When given an Android instrumentation .apk file as input, the parser returns the fully qualified method names of the tests that match JUnit 3 and JUnit 4 conventions.

To test this in a local environment:

  1. Download the dex-test-parser binary.

  2. Run the following command to get the list of test methods that will run on Device Farm:

    java -jar parser.jar path/to/apk path/for/output