Firstly,I would like to thank my family:Laura,Augusto and Octavio for their patience and consideration.The time I borrowed to achieve this goal was mostly theirs. onal friend and in3 azing adventure more than 15 ve pioneered the provision of Linux services and su 82npm in South America.He certainly taught me to be a bit more consultant and a bit less hacker(but I'm a very bad student:))And special thanks to Ricston's Peter Delia with whom we started providing 200 reality dictated by the market. And lastly I would like to thank all the reviewers and the Packt Publishing team who gave me their opinior n,suggestions,and corrections on early manuscripts;wit out them the book would never have had the quality it endowed www.allitebooks.com
Firstly, I would like to thank my family: Laura, Augusto and Octavio for their patience and consideration. The time I borrowed to achieve this goal was mostly theirs. Secondly I would like to thank my personal friend and IN3 Integracion Informatica co-founder, Caludio Palonsky, with whom we started this amazing adventure more than 15 years ago when we pioneered the provision of Linux services and support to enterprises in South America. He certainly taught me to be a bit more consultant and a bit less hacker (but I'm a very bad student :-)). And special thanks to Ricston's Peter Delia with whom we started providing Android training services throughout Europe as early as mid 2008 when Android was just a beautiful dream of having a mainstream Open Source operating system in the mobile arena. This is now a reality dictated by the market. And lastly I would like to thank all the reviewers and the Packt Publishing team who gave me their opinion, suggestions, and corrections on early manuscripts; without them the book would never have had the quality it endowed. www.allitebooks.com
About the Reviewers Paul Bourdeaux is the Senior Software Engineer and Application Development Team Lead at Sundog,a marketing and technology company based in the Midwest. He has a strong background in traditional software engineering,has authored several white ul is the a Dase Noah Eltzroth teaches dynamic web development at the Sullivan College of Technology and Design in Louisville,Kentucky.He enjoys working on a variety of 、Aa中pih出心hnysp8品haan& Tomas Malmsten has been working with software development for over a decade.During this time he has had the opportunity to work with a vast variety of technologies in various different business settings.His main focus has been the Java as worked with everything from large enterprise systems to Tomas is a passionate software craftsman who strives for exceller nFrom customer service and interaction to well craftent You can get in touch with Tomas through any of the following means Blog:http://www.tomasmalmsten.com .Twitter:http://twitter.com/tomasmalmster E-mail:publicetomasmalmsten.com LinkedIn:http://se.linkedin.com/in/tomasmalmster www.allitebooks.com
About the Reviewers Paul Bourdeaux is the Senior Software Engineer and Application Development Team Lead at Sundog, a marketing and technology company based in the Midwest. He has a strong background in traditional software engineering, has authored several white papers relating to mobile marketing and software engineering, and has presented at both national and regional software engineering conferences. Paul is the mobile marketing expert at Sundog, and his passion lies in mobile and cloud based software engineering. Noah Eltzroth teaches dynamic web development at the Sullivan College of Technology and Design in Louisville, Kentucky. He enjoys working on a variety of different software projects including business-oriented portals, data processing, and Android applications. In his free time, Noah enjoys programming in both Java and PHP. Tomas Malmsten has been working with software development for over a decade. During this time he has had the opportunity to work with a vast variety of technologies in various different business settings. His main focus has been the Java ecosystem where he has worked with everything from large enterprise systems to Android application development. Tomas is a passionate software craftsman who strives for excellence in all aspects of programming. From customer service and interaction to well crafted maintainable programs. You can get in touch with Tomas through any of the following means: • Blog: http://www.tomasmalmsten.com • Twitter: http://twitter.com/tomasmalmsten • E-mail: public@tomasmalmsten.com • LinkedIn: http://se.linkedin.com/in/tomasmalmsten www.allitebooks.com
ees from the technical universit Gabor Paller receivediNd lapest in 1992 and 1996.r Positionn Nokia and Nok Research Center.Hisintersts included wireles After having left kia,he worked at On -mobile con s,and the e ne works on IMS ks popular My ife reviewed a n ber Abhinav Tyagi is a Computer Science graduate from Pune.He also holds a post graduate diploma in Advanced Computing from CDAC,Pune.He developed several applications while working as a Software Engineer at Antarix Networks, e to thank Joel Goveya and Tarun Singh for giving me this www.allitebooks.com
Gábor Paller received his MSc. and PhD. degrees from the Technical University of Budapest in 1992 and 1996, respectively. Dr. Paller joined Nokia in 1998 and held positions in Nokia R&D and Nokia Research Center. His interests included wireless protocol development, mobile device management, mobile Java and middleware. He was also involved in standardization and joint research program activities. After having left Nokia, he worked at OnRelay Ltd. on fixed-mobile convergence technologies, and then in 2010 he joined Ericsson where he works on IMS. Gabor Paller runs the popular My Life with Android blog and reviewed a number of Android books. Abhinav Tyagi is a Computer Science graduate from Pune. He also holds a post graduate diploma in Advanced Computing from CDAC, Pune. He developed several Android applications while working as a Software Engineer at Antarix Networks, Mumbai. He is currently working on telecom protocols as a Research & Development Engineer at Nokia Siemens Networks. I would like to thank Joel Goveya and Tarun Singh for giving me this wonderful opportunity. www.allitebooks.com
www.PacktPub.com Support files,eBooks,discount offers and more You might want to visit www.Packtpub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published,with PDF and ePub files available?You can upgrade to the eBook version at www.PacktPub. com and as a print book customer,you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com,you can also read a collection of free technical articles,sign 思kcamaecokeawstesandoeaneowethsnedoumsandaiasomh PACKTLiB http://PacktLib.PacktPub.com PacktLib s Pack's nline digital books Why Subscribe? Fully searchable across every book published by Packt .Copy and paste,print and bookmark content On demand and accessible via web browser Free Access for Packt account holders for immediate access. www.allitebooks.com
www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub. com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? • Fully searchable across every book published by Packt • Copy and paste, print and bookmark content • On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. www.allitebooks.com
Table of Contents Preface Chapter 1:Getting Started with Testing Brief history Software bugs 8 How bugs severely affect your projects Why,what,how,and when to test nat to test The test fixture hod t 9122233555660022 Performance tests System tests 3 Android testing framework Instrumentation Test targets Summary 3232526 Chapter 2:Testing on Android JUnit Creating the Android main project Creating the Android test project 29 www.allitebooks.com
Table of Contents Preface 1 Chapter 1: Getting Started with Testing 7 Brief history 7 Software bugs 8 How bugs severely affect your projects 9 Why, what, how, and when to test 9 What to test 11 Activity lifecycle events 12 Database and filesystem operations 12 Physical characteristics of the device 12 Types of tests 13 Unit tests 13 The test fixture 15 The setUp() method 15 The tearDown() method 15 Test preconditions 16 The actual tests 16 Integration tests 20 Functional or acceptance tests 20 Test case scenario 22 Performance tests 22 System tests 23 Android testing framework 23 Instrumentation 23 Test targets 25 Summary 26 Chapter 2: Testing on Android 27 JUnit 28 Creating the Android main project 28 Creating the Android test project 29 www.allitebooks.com