Android APP Testing Tutorial with Automation Framework

Why Android Testing?

Android is the largest operating system in the world. At the same time, Android is fragmented. there are tons of devices and Android versions that your app must be compatible with. It doesn't matter how much time you invest  in design and implementation , mistakes are inevitable, and bugs will appear.

  1. Unit Test
  2. Integration Test
  3. Operational Test
  4. System Test
Unit Tests include sets of one or more programs which are designed to verify an atomic unit of source code, such as a method or a class.

Android platform comes pre-integrated Junit 3.0 framework. It's open source framework for automating Unit Testing. Android Testing Framework is powerful tool for developer to write the effective unit test program.

Complete Guide to Android Testing & Automation An addition to Unit Testing is User Interface (UI) tests. These tests relate to UI components of your target application. UI tests ensure that your application return the correct UI output in response to sequence of user actions on device.

Complete Guide to Android Testing & Automation The common way to performance UI tests on device is Android Instrumentation. But this has performance issues. One of the best tools to conduct UI testing on Android is Robotium .

Integration tests

In Integration Testing, all unit tested modules, are combined and verified. In Android, integration tests often involve checking integration withAndroid components such as Service testing, Activity testing, Content Provider testing, etc

Complete Guide to Android Testing & Automation There's many testing frameworks are used to conduct integration test for Android such as Troyd, Robolectric, Robotium.

Operational tests

System tests

In System Testing the system is tested as a whole and the interaction between the components, software and hardware is checked.

In Android, System Testing normally includes

In the above list, Performance Testing is given more focus. You can use tools like Traceview to conduct performance test on Android .This tool can help you debug your application and profile its performance.

Automated ANDROID TESTING

As android is fragmented, testing on multitude of devices is necessary. But this will also cost you money. Automated Android Testing can help reduce costs

Benefits of automated android testing

We will study the following 2 frameworks

Android testing framework

One of the standard testing frameworks for Android application is Android testing framework. It is a powerful and easy-to-use testing framework that is well integrated with the Android SDK tools.

Complete Guide to Android Testing & Automation          2a)  Test tools: A SDK tools for building test. They are integrated in Eclipse IDE or run as command line.

         2b)  MonkeyRunner: A tool that provides APIs for writing program which control an Android device or emulator outside of Android code.

  1. Test package are organized into test projects. This package follows naming convention. If the application under test has a package name of "com.mydomain.myapp"  than Test package should be "com.mydomain.myapp.test" .Test package includes 2 objects as below:

         3a)  Test case classes:include test methods to executed on target application.

         3b)  Mock objects : includes mock data that will be used as sample input  for test cases.

Android Test Case Classes

Complete Guide to Android Testing & Automation Below is an example of ActivityInstrumentationTestCase. It verifies the UI operation of Calculator application, check the correctness of the UI outputs.

Complete Guide to Android Testing & Automation Testing using Android Testing framework with device or emulator is difficult. Building and running test is slow and take much development effort. To fix this problem, there's another choice - Robolectric testing framework.

Robolectric framework allows you to run Android tests directly on JVM without the need for a device or an emulator.

Complete Guide to Android Testing & Automation

Advance features of Robolectric

Robolectric Test Case Classes

Myth #1:All Android devices are the same... test on emulators is enough

Let's start with a simple example. An application works perfectly on emulator s but on some real devices, it crashes during execution In this tutorial, you will learn- What is Real Testing Device? What is Emulators? Difference...

Mobile Testing

Top 20 Mobile Testing Interview Questions & Answers

Following are frequently asked mobile application testing interview questions and answers for...

Mobile Testing

15+ BEST Mobile Testing Service Provider Companies

Mobile testing is the procedure in which the mobile apps are tested for functionality, usability,...

Mobile Testing

APPIUM Tutorial for Android & iOS Mobile Apps Testing

What is Appium? APPIUM is a freely distributed open source mobile application UI Testing...

Mobile Testing

UIAutomatorViewer Tutorial: Inspector for Android Testing

What is UiAutomatorViewer? "UIautomatorviewer" is a GUI tool to scan and analyze the UI components of an...

Mobile Testing

iOS App Testing Tutorial: Manual & Automation

What is iOS App Testing? iOS App Testing is a testing process in which an iOS application is...