An Approach to Android Testing
With just about every OEM utilising the android ecosystem to come up with smart devices with different RAMs, screen sizes, cloud based platforms and not to miss the ever increasing list of complex apps, the android developers and testers have their tasks cut out. Fortunately for them there is no derth of testing methods and multiple frameworks in the market for testing on android platforms. In this article, we briefly talk about some of these widely used testing methods and frameworks for the Android environment.
Test Structures used in Android Testing
Most of the android testing of today is based on JUnit. Basically Junit test method utilizes statements to test parts of an android application. These test statements are organised into classes called test cases. A combination of test cases forms a test suite.
How to run the Test Structures?
The test suits are run on JUnit as well as the well known official android integrated development environment, Android Studio. Depending on the testing environment, there are two different ways to run test structures for android:
- Local machine run: The compiled test cases are executed locally on the Java Virtual Machine using the services of the JUnit tester.
- Emulator run:
One of the features of android studio is the ability to combine a couple of test source files and build a test app. In this method, the test app and the app under test are installed on an emulator; the tests are then run using an android specific test runner like AndroidJUnitRunner.
Types of Testing for Android Environment
- Cross app component testing:
This is used for verifying correct interactions between different user apps or the interactions between apps and system apps.
- Component testing of android apps:
This involves testing the app for correct or expected behaviour when the user performs a particular action or gives a certain input to the app.
- Instrumented Unit tests:
Run on an android device, these tests target the instrumentalities involved in creation of app and focus on the app’s objective. These can be run on an emulator also.
Role of Application programming interface (API) tools in android testing
There are API tools for building and running of test codes for android apps using automation. Here is a brief description of some of the popular APIs used widely:
Robotium provides black-box test cases for native as well as hybrid android apps. It can also provide functional, system and user acceptability test case scenarios for applications which may or may not have source code.
One of the best frameworks for UI testing of android apps, espresso is supported for testing on Froyo, gingerbread, icecream sandwich as well as the other android OS versions released after them. Though lacking in support for testing in webviews, espresso is extremely quick in synchronizing with UI threads.
UIautomator is useful for testing android apps and games. Besides, it facilitates testing of native android apps on more than one device. It can also run JUnit test cases for different processes.