Click here to Skip to main content
Click here to Skip to main content

Tips for Android Application Automation Testing

, 5 Oct 2012
Rate this:
Please Sign up or sign in to vote.
Testing for Android is especially important because of differences between the devices. Here are some tips.

Introduction

Testing is a very important part of the application development process. Testing for Android is especially important because of differences between the devices:

  • Screen size and resolution
  • Version
  • Form factor
  • The presence of front-facing camera, NFC, external keyboard, etc.

That’s why you need test applications on plenty of devices. Testing process consists of different testing types.

Let’s consider manual execution of functional testing. The tester sets up the application into the device, thoughtfully checks all the functionality, and then returns the device to its original state. The same actions are for each application and device. As you know, regular testing is time consuming and that is a big disadvantage of this technique.

Regular execution without big expenses is an obvious benefit of automated testing. For example, you can test a new application build on the available devices every night and analyze the results and fix the bugs in the morning.

Below we’ll consider the means of automated testing implementation. These are only included in the Android SDK or released under Open Source license tools.

The Automated Test Concept

Our task is automating the actions which were performed by the tester in the most accurate way. We have several applications and Android devices. Let’s apply the next steps for each of the items:

  • Install application on the device
  • Run the application
  • Test the application by selected technique
  • Delete the application
  • Reset the device

You need to collect and analyze data like logs and screenshots at every step. After that, you need to generate the test results based on these data form.

Android Devices Management

First, you need to find the computer on which the automated test will be run and customize the Android SDK. Examples are provided for computers with installed Linux.

Disable the lock out screen and maximize the latency-time on all tested devices. For some test techniques, you need to switch off changing screen orientation.

There are two utilities for devices management on the Android SDK: adb and MonkeyRunner.

Controlling by Android ADB Utility

ADB (Android Debug Bridge) is a utility to manage Android devices from the command line.

Adb utility is located in the directory: / platform-tools /. The path to this directory is recommended to write in PATH environment variable.

Checking the ADB Running

Install and customize the Android SDK, connect Android devices to your computer and run the next command:

adb devices

The command will show connected devices list. ADB is up and running if the device list is not empty.

Working with Several Devices

To show ADB the device to work with, you need to write the serial number of that device after the –s key:

adb-s <serial_number> <command /></serial_number>

For example:

adb-s <serial_number> logcat</serial_number>

You can see the serial number of the device by adb devices command. The –s key allows you to work with several connected devices at the same time, sets the default filter spec to silent. We won’t specify the -s key in the following commands.

Basic ADB Commands

The next command begins shell connection with device:

adb shell

Running command on the device:

adb shell <command />

There are many standard Linux utilities in Android, such as ls, cat, dmesg, etc.

Installing application from apk file:

adb install example.apk

Uninstalling application:

adb uninstall <package />

Getting the name of the package from apk file:

aapt dump badging example.apk | grep "package"

Receiving files from the device:

adb pull <path-on-device> <file /></path-on-device>

Sending files to the device:

adb push <file> <path-on-device /></file>

Note

Only read-access is available for most of the device directories. Write-access is allowed into the next directory: / sdcard (you can’t run the program from it) and / data / local / tmp /.

Running the application:

adb shell am start-n <package> / <activity /></package>

Running the specified activity. You can get from apk file name of the activity that is run when you select application in the menu, by the next command:

aapt dump badging example.apk | grep "launchable-activity"

Reading Logs

logcat utility allows reading additional log messages in Android. Read logs from the device (locked until you press Ctrl+C):

adb logcat

Clean log buffer on the device:

adb logcat-c

Dump the log to the screen and exit:

adb logcat-d

Screen Capturing by Utility screenCap

ScreenCap utility saves the current contents of the screen to a graphic file:

adb shell screencap / sdcard / screen.png
adb pull / sdcard / screen.png screen.png
adb shell rm / sdcard / screen.png

ScreenCap utility is available on phones with Android 4.x and the next versions. On previous versions of Android, capturing of screenshots can be made by MonkeyRunner.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Qarea Team
QArea - software outsourcing company
United States United States
QArea is a software development outsourcing company that specializes in wide range of professional fields:
 
- custom software development
- software testing
- web development
- mobile applications development
 
Our company has a huge experience in these fields and we are always glad to share our knowledge with others. We are looking forward you to find our articles and tips useful.
 
Visit our website: www.qarea.com
Follow on   Twitter

Comments and Discussions

 
Questionwhy is this in c# Pinmembergashach5-Oct-12 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 5 Oct 2012
Article Copyright 2012 by Qarea Team
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid