Book Image

Android Application Testing Guide

By : Diego Torres Milano
Book Image

Android Application Testing Guide

By: Diego Torres Milano

Overview of this book

<p>It doesn't matter how much time you invest in Android design, or even how careful you are when programming; mistakes are inevitable and bugs will appear. This book will help you minimize the impact of these errors in your Android project and increase your development productivity. It will show you the problems that are easily avoided, to help get you quickly to the testing stage.<br /><br />Android Application Testing Guide is the first and only book providing a practical introduction to the most common available techniques, frameworks, and tools to improve the development of your Android applications. Clear, step-by-step instructions show how to write tests for your applications and assure quality control using various methodologies.<br /><br />The author's experience in applying application testing techniques to real world projects enables him to share insights on creating professional Android applications. <br /><br />The book starts by introducing Test Driven Development, which is an agile component of the software development process and a technique where you will tackle bugs early on. From the most basic unit tests applied to a sample project to more sophisticated performance tests, this book provides a detailed description of the most widely used techniques in the Android testing world in a recipe-based approach.<br /><br />The author has extensive experience of working on various development projects throughout his professional career. All this research and knowledge has helped create a book that will serve as a useful resource to any developer navigating the world of Android testing.</p>
Table of Contents (17 chapters)
Android Application Testing Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Assertions in depth


Assertions are methods that should check for a condition that could be evaluated and throw an exception if the condition is not met, thus aborting the execution of the test.

The JUnit API includes the class Assert, which is the base class all of the test case classes. It holds several assertion methods useful for writing tests. These inherited methods test for a variety of conditions and are overloaded to support different parameter types. They can be grouped together in different sets, depending on the condition checked; for example:

  • assertEquals

  • assertFalse

  • assertNotNull

  • assertNotSame

  • assertNull

  • assertSame

  • assertTrue

  • fail

The condition tested is pretty obvious and easily identifiable by the method name. Perhaps the ones that deserve some attention are assertEquals() and assertSame(). The former when used on objects asserts that both objects passed as parameters are equal, calling the objects' equals() method. The latter asserts that both objects refer to the...