home Mobile Testing Android Application Testing Guide

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.

Facebooktwittergoogle_plusredditpinterestlinkedinmail
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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe