Android Application Testing Guide

Testing appears to be the least popular topic in Android development circles based on the relatively few books on Android app testing. Most tend to focus on development because, unfortunately (but true), application testing isn’t be something most developers think much about, or if they do, they don’t do it systematically (I’m guilty of this as well). This book has allowed me to expand my horizon by learning from the pros.

The “Android Application Testing Guide” is a very practical book introducing available frameworks and most widely used tools & techniques to improve the quality of Android applications by engaging in quality control and testing throughout the development cycle, not just testing at the end. The Agile development concept, called the Test Driven Development (TDD), relies on repeatable short cycles to catch and address potential defects (i.e., bugs) as early as possible.

The first chapter explains what’s involved in the different stages of testing in Android development including unit tests, integration tests, functional or acceptance tests, system tests and performance tests. It introduces the Android testing framework extending JUnit which provides the complete testing framework suitable for the end-to-end testing strategies.

Chapter 2 deals with testing with JUnit which is the default framework for any Android testing project and is supported by Eclipse , the most widely-used IDE for Android development. The chapter jumps right into a step-by-step on how to create an Android test project separate from the development project being tested. The test project will have an independent structure and a set of its own components. Having a separate project is the best practice because from a production build’s standpoint, testing codes will not be included in the actual build, thus it will be not be in the APK.

Chapter 3 dives into individual building blocks in the Android SDK tool. This covers Assertions, TouchUtils class (to simulate the touch events), Mock objects (to simulate mock objects in order to isolate the tests), TestCase class, and Instrumentation. There is an extensive explanation of each individual component accompanied by code samples.

Chapter 4 talks about the concept of Test Driven Development. Again, it is the strategy of performing tests along the development process – not at the end as in the traditional approach. This even includes writing test cases (and test codes) right after studying the requirements, and then writing the actual code to satisfy (having attained “pass” results) the test cases. The author claims that creating test cases early on will help ensure that tests will be performed. Delaying testing makes it highly possible tests will forgotten or ignored. I agree with the concept, but in reality, this may not work for projects. Even the author advises to use judgment and expertise in applying the approach wherever suitable. The latter part of the chapter shows examples of applying TDD in step-by-step sample applications and tests, which makes the case very compelling.

Chapter 5 introduces the Android Virtual Device (AVD), the next best thing to real devices. The obvious advantage of AVD is the ability to create a variety of Android configurations to run tests. The Headless Emulator is also mentioned. This enables automating tests via command line with no windows. I really enjoyed the samples of what you can do with command-lines, especially simulating different device conditions including network bandwidth throttling, different locales, etc. Later in the chapter, it talks about the support of the Monkey application (you can read more about Monkey Theorem here) which allows random event generation. It also demos the server-client setup and test scripting with Monkeyrunner.

Chapter 6 discusses the Behavior Driven Development approach, which according to author is considered the evolution of TDD and a need for Acceptance Testing. The approach emphasizes not only business or end users in testing, but also to use non-technical terms in the test cases that business or end users would understand. Personally, I think the concept is more abstract than practical. However, the introduction of Fitnesse and Slim tools point out this concept’s usefulness especially in terms of “Wiki”-style test cases and test result documentation.

Chapter 7 contains practical, real-world samples of the disciplines and techniques you can use in different situations. This includes testing activities and applications, databases and Content Providers, UIs, exceptions, parsers and memory leaks. A couple of tools are introduced here including EasyMock which provides mock objects for interfaces, and Hamcrest which is a library of matcher objects for comparison.

Chapter 8 expands on the Agile technique with continuous integration. Similar to continuous testing, the author suggests that integration should be done frequently and early in the process in small steps. The most common practice is to trigger the build process after every submission to the source code repository. The chapter goes into detail on how to setup an automation building process using ant, version control repository using Git, continuous integration with Hudson, and test result analysis using nbandroid-utils.

Chapter 9 discusses one of the most critical components in designing Android applications – performance. As we all know, mobile devices are unique and balancing between performance and effective use of resources is something developers must keep in mind when designing an Android application. The chapter contains an outline of tools and techniques for performance testing. This includes using traditional LogCatlogging, extending Instrumentation, Traceview, dmtracedump, and Caliper microbenchmarks.

Chapter 10 states that alternative testing tactics are not for most Android developers as it involves building Android from source code, and introduces more testing tools. Even though it is very technical, it is still a good read.

Summary:

I have to say that as a novice Android developer I learned a lot from reading the Android Application Testing Guide. Best-in-class testing techniques commonly practiced in Agile development are covered in this book. These include Test Driven Development, Behavior Driven Development, Continuous Integration as well as others. The traditional approach of testing and integration at the end of development cycle is generally opposed. However, as the author states in the book, there are no silver bullets in software development – the suggested testing approaches might not apply to certain needs or projects. It is clear that for a large, complex project, applying the methods and techniques as described will likely increase the productivity and quality of your apps.

Numerous tools are introduced in this book. This may be one of the big issues for those who are less-advanced in Android development. Since there is no common repository for these tools, extended knowledge of a variety of open-source tools, and the ability to incorporate them in the development process are vital. I wish that there were a consolidated repository for all testing tools or even better – all required testing functionality would be built-in in the SDK. But while we wait for that to happen, the Android Application Testing Guide is one of a few reference books I’m aware of that has the complete collection of Android testing topics.

Ittichai

Ittichai has been involved in many aspects of Oracle database technologies including RAC, ASM, Data Guard and Streams. He enjoys working on database and SQL performance tunings. He’s also interested in rapid web development using Oracle APEX.

He is currently an IT technical manager and data warehouse architect with Motorola Solutions.

Ittichai Chamavanijakul
Ittichai has been involved in many aspects of Oracle database technologies including RAC, ASM, Data Guard and Streams. He enjoys working on database and SQL performance tunings. He’s also interested in rapid web development using Oracle APEX.He is currently an IT technical manager and data warehouse architect with Motorola Solutions.

The Related Post

Strategies to Approach Mobile Web App Testing Mobile web technology has been continuously changing over the past few years, making “keeping up” challenging. In this article, Raj Subramanian covers the latest trends and changes happening in the mobile web and how testers can prepare for them.
Great mobile testing requires creativity to find problems that matter. I’d like to take you through the thought process of testers and discuss the types of things they consider when testing a mobile app. The intention here is to highlight their thought processes and to show the coverage and depth that testers often go to.
In today’s mobile-first world, a good app is important, meaning an effective Mobile Testing strategy is  essential.  
Don’t make the mistake of assuming too many similarities. It is common knowledge that mobile applications don’t function in the same way as their web-based counterparts. The user experience is affected by a few other factors such as device and network capability. If you are building out a performance testing strategy for your mobile website ...
I am not a big fan of concepts which moves industry standards to IT. I am rather a Agile and Scrum guy. Managing multiple projects at once and trying to set a highest quality standard is a challenge and this book shows how industrial language can be translated into software development. I do not think that it ...
Drawing from the Greek mythology of the lotus eaters, Anne-Marie Charrett warns testers to be weary of enjoying early success too soon upon finding high impact bugs.
iOS culture, even in many large organizations with skilled engineers, is behind on up-to-date testing practices. Agile development has long been all the rage; indeed, in most modern development shops the great agile methodologies are old hat. If you come from a software background like Ruby on Rails, Python, or certain Java niches, you may–until ...
What you need to know in order to have effective and reliable Test Automation for your mobile apps I realized that Test Automation interfaces are pivotal to effective and efficient Test Automation, yet very few people trying to test their mobile apps seemed to know how their automated tests connected with the apps they wanted ...
Users aren’t likely to forgive and forget buggy apps. Mobile has big implications for business. The mobile experience is the customer experience, and you don’t get many second chances.
By focusing on test design, analyzing test requirements and optimizing the approach to testing, it’s possible to maximize mobile test automation cost effectively. In a previous article we outlined the importance of understanding the mobile ecosystem and test design for planning and executing mobile testing. The focus of this article is about efficient mobile test ...
Devices matter. We don’t yet trust the mobile devices like we trust desktops and laptops. In the course of testing traditional web applications, rarely do you have to think about the model of the actual machine. In mobile, however, the behavior of an application can vary from device to device. You can no longer just ...
  LogiGear_Magazine_September 2016_Testing SMAC Down  

Leave a Reply

Your email address will not be published.

Stay in the loop with the lastest
software testing news

Subscribe