16 August, 2013

How to Perform Android Automated Testing


Android app development
Android app testing is an essential part of the development process. Especially for Android OS, it is very important because the devices are very different from each other. They vary from each other in screen size and resolution, version, form factor, instruction set of the processor, front camera, NFC, external keyboard and so many other different factors. In such a scenario, automated Android testing provides an architecture and powerful tools that tests every aspect of android application at every level from unit to framework.

Many Android test suites are based on JUnit. The Android JUnit extensions provide component-specific test case classes. JUnit extensions test Android API. A functional test checks if the activity was correctly started. A unit test just tests the functionality of a certain component. These classes provide helper methods for creating mock objects and methods that help one control the lifecycle of a component.

Android SDK tools are available in plenty for building and testing such as Eclipse with ADT and also in command-line form for use with other IDEs. These tools gather data from the application under test and use this information to automatically create file, manifest both the file as well as directory structure for the test package. There are two utilities available in Android SDK to control Android devices: ADB (Android Debug Bridge) and Monkeyrunner. Monkeyrunner is an API used for testing devices with Python programs and its UI is a command-line tool for stress-testing. These two send pseudo-random events to a device.

The Android SDK provides the following tools to support automated, functional UI testing for its application:
  • uiautomatorviewer - A GUI tool to scan and analyze the UI components of an Android application.
  • uiautomator - A Java library containing APIs to create customized functional UI tests and an execution engine to automate and run the tests.
  • InstrumentationTestRunner - A primary Android test runner class which extends JUnit test runner. framework.It runs any the test case classes provided by Android and supports all possible types of testing.
If one plans to test the application, the app must be installed first on a test device, analyzed UI components of the app and must be ensured that the application is accessible by the test automation framework.

1. Create automated tests to simulate specific user interactions on application.
2. Compile test cases into a JAR file and install it on test device along with your app.
3. Run the tests and view the test results.
4. Correct any bugs or defects discovered in testing.

Various Automated Testing methods used are:
  • Testing with Monkey
  • Testing with MonkeyRunner
  • Testing with getevent and sendevent
  • Testing with Robotium
These methods can work wonders testing the android apps. A properly constructed testing process that combines different testing methods including automated testing is an essential part of a high quality application development process.

Advantages of Android Automated Testing
  • It brings flexibility to the application.
  • Programming skills are not required to record event sequence.
  • Actions are described at the application UI level.
  • Script does not depend of the screen orientation and screen resolution.
  • Automated scripts can check the state of an application only after an action.
  • Avoids redundancy of effort in testing.
With the above advantages, developers can leverage automated android app testing methods and techniques to make their lives easier and mobile app development fun!

We provide android app development services. If you would like to hire android app programmers from our team, please get in touch with us at Mindfire Solutions.

No comments: