The Wayback Machine - https://web.archive.org/web/20160318184253/https://www.packtpub.com/application-development/learning-android-application-testing

Learning Android Application Testing

Improve your Android applications through intensive testing and debugging

Learning Android Application Testing

Learning
Paul Blundell, Diego Torres Milano

Improve your Android applications through intensive testing and debugging
$20.00
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

+ Collection
Free Sample

Book Details

ISBN 139781784395339
Paperback274 pages

Book Description

This book is a practical introduction to readily available techniques, frameworks, and tools to thoroughly test your Android applications and improve project development.

You will learn the Java testing framework, how to create a test case and debug it. Next, you'll be walked through using the Android SDK to test using the ActivityTestCase and ActivityUnitTest classes as well as discussing popular testing libraries. Through examples you will test files, databases, ContentProviders, exceptions, services, and test your app using Espresso. You will discover how to manage your Android testing environment using Android emulators, deep dive into how adb and the emulator can super charge your testing automation, and also test user interactions with monkeyrunner. You will be guided through different testing methodologies including Test-driven Development and Behavior-driven Development and will learn how to perform Unit and Functional testing applying them to your Android projects. You will also use continuous integration techniques for ultimate application quality control using Gradle and Jenkins.

By the end of the book, you'll be looking through alternative testing tactics including Fest and Spoon to build upon and expand your Android testing range and finesse.

Table of Contents

Chapter 1: Getting Started with Testing
Why, what, how, and when to test?
Types of tests
Java testing framework
Android testing framework
Creating the Android project
Summary
Chapter 2: Understanding Testing with 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<T> class
The ServiceTestCase<T>
The TestSuiteBuilder.FailedToCreateTests class
Using libraries in test projects
Summary
Chapter 3: Baking with Testing Recipes
Android unit tests
Testing activities and applications
Testing files, databases, and content providers
Testing exceptions
Testing local and remote services
Extensive use of mock objects
Testing views in isolation
Testing parsers
The parser test
Testing for memory usage
Testing with Espresso
Summary
Chapter 4: Managing Your Android Testing Environment
Creating Android Virtual Devices
Running AVDs from the command line
Additional emulator configurations
Speeding up your AVD with HAXM
Alternatives to the AVD
Running monkey
Test scripting with monkeyrunner
Summary
Chapter 5: Discovering Continuous Integration
Building Android applications manually using Gradle
Git – the fast version control system
Continuous integration with Jenkins
Summary
Chapter 6: Practicing Test-driven Development
Getting started with TDD
Creating a sample project – the temperature converter
Creating a Java module
Creating the TemperatureConverterActivityTests class
Adding functionality
Viewing our final application
Summary
Chapter 7: Behavior-driven Development
Given, When, and Then
FitNesse
GivWenZen
Summary
Chapter 8: Testing and Profiling Performance
Ye Olde Logge method
Timing logger
Performance tests in Android SDK
Using the Traceview and dmtracedump platform tools
Dmtracedump
Microbenchmarks
Summary
Chapter 9: Alternative Testing Tactics
Code coverage
Temperature converter code coverage
Introducing Robotium
Testing on the host's JVM
Introducing Robolectric
Google's march on shadows
Introducing Fest
Introducing Spoon
Introducing Fork
Summary

What You Will Learn

  • Apply testing techniques and utilize tools to improve Android application development
  • Get to grips with the nuances of testing on Android, including how to architect an application to facilitate better testing
  • Explore the Android instrumentation testing framework to optimize your activities, services, content providers, and usage of other Android components
  • Understand different development methodologies including Test-driven Development and Behavior-driven Development
  • Apply the continuous integration technique for ultimate application quality control
  • Improve application performance by analyzing the results returned from performance tests
  • Expose your application to a wide range of conditions and configurations to simulate real-life network conditions and detect problems in the application
  • Explore further tools to improve application quality such as micro benchmarks and code coverage

Authors

Table of Contents

Chapter 1: Getting Started with Testing
Why, what, how, and when to test?
Types of tests
Java testing framework
Android testing framework
Creating the Android project
Summary
Chapter 2: Understanding Testing with 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<T> class
The ServiceTestCase<T>
The TestSuiteBuilder.FailedToCreateTests class
Using libraries in test projects
Summary
Chapter 3: Baking with Testing Recipes
Android unit tests
Testing activities and applications
Testing files, databases, and content providers
Testing exceptions
Testing local and remote services
Extensive use of mock objects
Testing views in isolation
Testing parsers
The parser test
Testing for memory usage
Testing with Espresso
Summary
Chapter 4: Managing Your Android Testing Environment
Creating Android Virtual Devices
Running AVDs from the command line
Additional emulator configurations
Speeding up your AVD with HAXM
Alternatives to the AVD
Running monkey
Test scripting with monkeyrunner
Summary
Chapter 5: Discovering Continuous Integration
Building Android applications manually using Gradle
Git – the fast version control system
Continuous integration with Jenkins
Summary
Chapter 6: Practicing Test-driven Development
Getting started with TDD
Creating a sample project – the temperature converter
Creating a Java module
Creating the TemperatureConverterActivityTests class
Adding functionality
Viewing our final application
Summary
Chapter 7: Behavior-driven Development
Given, When, and Then
FitNesse
GivWenZen
Summary
Chapter 8: Testing and Profiling Performance
Ye Olde Logge method
Timing logger
Performance tests in Android SDK
Using the Traceview and dmtracedump platform tools
Dmtracedump
Microbenchmarks
Summary
Chapter 9: Alternative Testing Tactics
Code coverage
Temperature converter code coverage
Introducing Robotium
Testing on the host's JVM
Introducing Robolectric
Google's march on shadows
Introducing Fest
Introducing Spoon
Introducing Fork
Summary

Book Details

ISBN 139781784395339
Paperback274 pages
Read More