Preface ttter how ireven howc en programming,mis It will sh ntrotctionothemostcommoniyaaibiemgbcPit Audroid arlication testing guide is the first and only book r actical 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. The author's experience in applying application testing techniques to real-world projects enables him to share insights on creating professional Android applications. 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 bas fnauenieAhodeagNoidimaepebaRdaAppoacdh e tes crption of th The author s deve pment career research and k knowledge has helped orld of Android test ve as a usefu resource to any developer navigating th What this book covers Chapter 1,Getting Started with Testing introduces the different types of testing and their applicability to software development projects in general and to Android in
Preface 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. Android Application Testing Guide is the first and only book providing a practical introduction to the most commonly-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. The author's experience in applying application testing techniques to real-world projects enables him to share insights on creating professional Android applications. 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. 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. What this book covers Chapter 1, Getting Started with Testing introduces the different types of testing and their applicability to software development projects in general and to Android in particular
Preface Chapter 2,Testing on Android covers testing on the Android platform,Unit testing and JUnit,creating an Android Test project,and running tests. Chapter 3,Building Blocks on the Android SDK starts digging a bit deeper to recognize the building blocks available to create the tests.It covers Assertions TouchUtils, ces,Moc k objects,Instrumentation,and TestCase class Chapter 4,Test Driven Development introduces the Test Driven Development intensive chapter Chapter 5, roid Testing provides different conditions to run th e tests the al Devi ces (h VD)to pro as a events used for testing. to gen Chapter 6,Belavior Driven Development introduces Behavior Driv cepts such as like the t press the tests and ment project. Chanter 7.Testing recines sdieaeranmtons actical examples of different mm vou will encounter a g the dis ciplines and technique mpee presenteoyoudsthem for your on rpes cover Android Unit tests,Actvts Applicatons,Datab Providers,Local and Remote Services,Uls,Exceptions,Parsers,and Memory leaks Chapter 8,Continous Integration introduces this agile technique for software time taker ated to b marking create. ing pro ols.T meth chapter r also prese Chapter 10,Alternative Tes vers buildi g m source,code erage using EMMA ing on hos and Robolectric. 【21
Preface [ 2 ] Chapter 2, Testing on Android covers testing on the Android platform, Unit testing and JUnit, creating an Android Test project, and running tests. Chapter 3, Building Blocks on the Android SDK starts digging a bit deeper to recognize the building blocks available to create the tests. It covers Assertions, TouchUtils, intended to test User Interfaces, Mock objects, Instrumentation, and TestCase class hierarchies featuring UML diagrams. Chapter 4, Test Driven Development introduces the Test Driven Development discipline. It starts with a general revision and later on moves to the concepts and techniques closely related to the Android platform. This is a code intensive chapter. Chapter 5, Android Testing Environment provides different conditions to run the tests. It starts with the creation of the Android Virtual Devices (AVD) to provide different conditions and configurations for the application under test and runs the tests using the available options. Finally, it introduces monkey as a way to generate simulated events used for testing. Chapter 6, Behavior Driven Development introduces Behavior Driven Development and some concepts such as like the use of a common vocabulary to express the tests and the inclusion of business participants in the software development project. Chapter 7, Testing Recipes provides practical examples of different common situations you will encounter applying the disciplines and techniques described before. The examples are presented in a Cookbook style so you can adapt and use them for your projects. The recipes cover Android Unit tests, Activities, Applications, Databases and ContentProviders, Local and Remote Services, UIs, Exceptions, Parsers, and Memory leaks. Chapter 8, Continuous Integration introduces this agile technique for software engineering that aims to improve the software quality and to reduce the time taken to integrate changes by continuously applying integration and testing frequently. Chapter 9, Performance Testing introduces a series of concepts related to benchmarking and profiles from traditional logging statement methods to Creating Android performance tests and using profiling tools. This chapter also presents Caliper to create microbenchmarks. Chapter 10, Alternative Testing Tactics covers building Android from source, code coverage using EMMA, Robotium, testing on hosts, and Robolectric
Preface What you need for this book you are familiar with the topics described extensively in the Android Dev Guide(http://developer.android.com/guide/index.html).Also it is very helpful having followed some of the Sample Code projects(http://developer. android.com/resources/browser.html?tag=sample),probably starting with API engto other more involved topics.This way you will get the Tobe able tofollow the and se ral other ations All the examples are based on: Ubuntu 10.04.2 LTS(lucid)64 bit,fully updated Java SE version"1.6.0_24"(build 1.6.0_24-b07) Android SDK tools,revision 11 Android SDK Platform-tools,revision4 SDK Platform Android 2.3.1.API9.revision 2 .Android Compatibility package,revision2 Eclipse IDE for Java Developers,Version:Helios Service Release 1(3.6.1) Android Development Toolkit,Version:10.0.1.v201103111512-110841 Dalvik Debug Monitor Service,Version:10.0.1.v201103111512-110841 Apache Ant version 1.8.0 compiled on April92010 ·Git version1.7.0.4 .Subversion version 1.6.6(r40053)compiled Mar 23 2011,13:08:34 The UML diagrams presented in the book were created using BOUML release 4.21 Screenshots were taken and edited using Shutter 0.86.3. Manuscripts were edited using OpenOffice.org 3.2.1. Who this book is for ons or optimize your elo nt pr srequired. No prev 【3]
Preface [ 3 ] What you need for this book First of all, you need practical Android development experience as we are not covering the basics. It is assumed that you already have some Android application or at least you are familiar with the topics described extensively in the Android Dev Guide (http://developer.android.com/guide/index.html). Also it is very helpful having followed some of the Sample Code projects (http://developer. android.com/resources/browser.html?tag=sample), probably starting with API Demos and then moving to other more involved topics. This way you will get the most of this book. To be able to follow the examples in the different chapters you need a common set of software and tools installed and several other components that are described in every chapter in particular including their respective download locations. All the examples are based on: • Ubuntu 10.04.2 LTS (lucid) 64 bit, fully updated • Java SE version "1.6.0_24" (build 1.6.0_24-b07) • Android SDK tools, revision 11 • Android SDK Platform-tools, revision 4 • SDK Platform Android 2.3.1, API 9, revision 2 • Android Compatibility package, revision 2 • Eclipse IDE for Java Developers, Version: Helios Service Release 1 (3.6.1) • Android Development Toolkit, Version: 10.0.1.v201103111512-110841 • Dalvik Debug Monitor Service, Version: 10.0.1.v201103111512-110841 • Apache Ant version 1.8.0 compiled on April 9 2010 • Git version 1.7.0.4 • Subversion version 1.6.6 (r40053) compiled Mar 23 2011, 13:08:34 The UML diagrams presented in the book were created using BOUML release 4.21. Screenshots were taken and edited using Shutter 0.86.3. Manuscripts were edited using OpenOffice.org 3.2.1. Who this book is for If you are an Android developer looking to test your applications or optimize your application development process, then this book is for you. No previous experience in application testing is required
Preface Conventions uish betweer explanation of their meaning. Code words in text are shown as follows:"To invoke the am command we will be using the adb shell command". A block of code is set as follows @VeryImportantTest public void testotherstuff(){ fail("Not implemented yet"); public class MyFirstProjectTests extends Testcase{ public MyFirstProjectTests(){ this("MyFirstProjectTests"); Any command-line input is written as follows: test.InstrumentationTestRunner Any command-line output is written as follows: 08-1000:26:11.820:ERROR/AndroidRuntime(510):FATALEXCEPTION:main scwterms and imp xes for example,appear in the text like this:h screen,in mer Project and then Run Warnings or important notes appear in a box like this. 【4]
Preface [ 4 ] Conventions In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. Code words in text are shown as follows: "To invoke the am command we will be using the adb shell command". A block of code is set as follows: @VeryImportantTest public void testOtherStuff() { fail("Not implemented yet"); } When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: public class MyFirstProjectTests extends TestCase { public MyFirstProjectTests() { this("MyFirstProjectTests"); } Any command-line input is written as follows: $ adb shell am instrument -w -e class com.example.aatg.myfirstproject. test.MyFirstProjectTests com.example.aatg.myfirstproject.test/android. test.InstrumentationTestRunner Any command-line output is written as follows: 08-10 00:26:11.820: ERROR/AndroidRuntime(510): FATAL EXCEPTION: main 08-10 00:26:11.820: ERROR/AndroidRuntime(510): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Select the test project and then Run As | Run Configurations". Warnings or important notes appear in a box like this
Preface Tips and tricks appear like this Reader feedback d or may an e-mail to feedbackapacktpub.com, If there is a book th us a note in orm on www.packtpub.com or e-mail topic that If there is a u have experti se in d you are interested in eithe ourauthor guide Customer support Now that you are the proud owner of a Packt book,we have a number of things to help you to get the most from your purchase. Downloading the example code You can download the example code files for all Packt books you have purchased rom your account at hetp://www.PacktPub.com.If you purcha ctly to you. /www.Packt Pub.com/support and register to have 【5] www.allitebooks.com
Preface [ 5 ] Tips and tricks appear like this. Reader feedback Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to feedback@packtpub.com, and mention the book title via the subject of your message. If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail suggest@packtpub.com. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors. Customer support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase. Downloading the example code You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you. www.allitebooks.com