PacktLib: Android Application Testing Guide

Android Application Testing Guide

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Getting Started with Testing

Brief history

Software bugs

Why, what, how, and when to test

Types of tests

Android testing framework

Summary

Testing on Android

JUnit

Creating the Android main project

Creating the Android test project

Package explorer

Creating a test case

Running the tests

Debugging tests

Other command-line options

Summary

Building Blocks on the Android SDK

The demonstration application

Assertions in depth

View assertions

Even more assertions

The TouchUtils class

Mock Objects

The TestCase base class

The AndroidTestCase base class

Instrumentation

The InstrumentationTestCase class

The ActivityTestCase class

The ActivityInstrumentationTestCase2 class

The ProviderTestCase2 class

The ServiceTestCase

The TestSuiteBuilder.FailedToCreateTests class

Using external libraries in test projects

Summary

Test Driven Development

Getting started with TDD

Creating a sample project—the Temperature Converter

Creating the TemperatureConverterActivityTests project

Adding functionality

Viewing our final application

Summary

Android Testing Environment

Creating Android Virtual Devices

Running AVDs from the command line

Additional emulator configurations

Running monkey

Test scripting with monkeyrunner

Summary

Behavior Driven Development

Brief history

Given, when, then

FitNesse

GivWenZen

Summary

Testing Recipes

Android Unit tests

Testing activities and applications

Testing files, databases, and ContentProviders

Testing exceptions

Testing local and remote services

Extensive use of mock objects

Testing Views in isolation

Testing parsers

Testing for memory leaks

Summary

Continuous Integration

Building Android applications manually using Ant

Git—the fast version control system

Continuous Integration with Hudson

Summary

Performance Testing and Profiling

Ye Olde Logge method

Performance tests in Android SDK

Using the Traceview and dmtracedump platform tools

Microbenchmarks

Summary

Alternative Testing Tactics

Building Android from source

TemperatureConverter code coverage

The undocumented Ant coverage target

Introducing Robotium

Testing on host's JVM

Introducing Robolectric

Summary

Index