A large number of Android automated testing architectures or tools are available to us, including Activity Instrumentation, MonkeyRunner, Robotium, and Robolectric.
In addition, LessPainful also provides services for automated testing on real devices.
Android provides basic support for the instrumentation test, one of which is the ActivityInstrumentationTestCase2 class located in the android. test package. It extends the TestCase class of JUnit to provide the Android activities function test. In the application test, each activity is first initialized by Instrumentation, and then loaded to the Android simulator or the Dalvik virtual machine of the device for execution.
The Android SDK comes with MonkeyRunner, a test tool that provides APIs and execution environments to run test code written in Python. It provides APIs to connect devices, install/unload applications, run applications, screenshots, and compare images to determine whether the screen after a specific command is executed contains the expected information, and run tests on the application. MonkeyRunner defines test cases using ActivityInstrumentationTestCase2, ProviderTestCase, ServiceTestCasek, SingleLaunchActivityTestCase, and other classes, and uses the InstrumentationTestRunner class to run the test.
Robotium is another architecture that uses InstrumentationTestRunner to perform Android interactive testing. It spans multiple activities and supports function testing, system testing, and acceptance testing. Robotium supports Activities, Dialogs, Toasts, Menus, Context Menus, and even Honeycomb. It can be integrated with Maven and Ant to complete continuous integration testing. Robotium is called another Selenium for Android applications.
Robolectric is a different method. It does not rely on the test function provided by Android. It uses shadow objects and runs the test on a common workstation/Server JVM, unlike simulators or devices that require the dexingAndroid dex compiler to compile class files into the Dalvik VM format on Android devices), the packaging, deployment, and running processes greatly reduce the test execution time. Pivotal labs claim that they can run 1047 tests within 28 seconds using Robolectric.
LessPainful has taken another step in Android testing. It provides a multi-device platform automated testing service. The user uploads an application (*. apk) and a service-related DSL with Cucumber). Select the device configuration required for the test, and the test will be executed automatically and generate the test report. It supports Garmin Asus, several HTC, LG, Samsung Galaxy, Sony Xperia, and Motorola Motodefy devices.