Friday, June 24, 2011

Using Android monkeyrunner to automate test steps

It is not unlikely that in writing your tests you discover that some simple steps are required by several tests.

 monkeyrunner is a great tool in this respect because it offers a tremendously powerful and complete language like python.
You can write your tests using python but also you can build libraries containing primitives belonging to the test domain.
This example shows how you can lock and unlock the device screen. Usually this methods should be in a different class or module but for the sake of simplicity we are including lockDevice() and unlockDevice() here in the main script.

#! /usr/bin/env monkeyrunner
Created on Jun 22, 2011

@author: diego

from import MonkeyRunner, MonkeyDevice

def lockDevice(device):
    return"POWER", MonkeyDevice.DOWN_AND_UP)

def unlockDevice(device):
    device.drag((130, 620), (350, 620), 1.0, 120)

def main():
    device = MonkeyRunner.waitForConnection()
    if device:

if __name__ == '__main__':

Now, a demonstration of this script running on a Nexus One, locking, waking up, and unlocking the screen.

Hope this helps you start creating you monkeyrunner libraries.
Comments are welcome.

Sunday, June 19, 2011

Save the date: Android Testing at LinuxCon North America 2011

Mark your calendars. On Wednesday August 17th, 2011, 10:30 (schedule) I will be presenting the tutorial Introduction to Android Testing. It will give you an overview of current methodologies and tools available on Android. This tutorial will also introduce Test Driven Development, Behaviour Driven Development and Continuous Integration, techniques that every serious development project should at least consider.

More information at LinuxCon North America 2011.
Hope to see you there.

Friday, June 03, 2011

Android Application Testing Guide

The wait is almost over and after a year of hard work the book is finished and is expected to be published by PACKT this month (June 2011).

You can Pre-order now !

Adroid Application Testing Guide is a highly detailed book which gives step-by-step examples for a great variety of real-world cases, providing professional guidelines and recommendations that will be extremely valuable for optimizing your development time and resources. In the chapters you will find an introduction to specific testing techniques, and tools for specific situations.

Overview of Android Application Testing Guide
  • The first and only book that focuses on testing Android applications
  • Step-by-step approach clearly explaining the most efficient testing methodologies
  • Real world examples with practical test cases that you can reuse
  • eBook available as PDF and ePub downloads and also on PacktLib
More detailed information can be obtained from its web page at PACKT.