Test-Driven iOS Development
Product Author Bios
Graham Lee is a well-known and outspoken member of the worldwide iOS/Mac developer community. A security consultant and contract developer for iOS and Mac application software, he has presented on high-quality software engineering practices for Cocoa developers at many conferences, including Voices That Matter, NSConference, the Association of C and C++ Users, and Qcon. He is author of Professional Cocoa Application Security.
As iOS apps become increasingly complex and business-critical, iOS developers must ensure consistently superior code quality. This means adopting best practices for creating and testing iOS apps. Test-Driven Development (TDD) is one of the most powerful of these best practices. Test-Driven iOS Development is the first book 100% focused on helping you successfully implement TDD and unit testing in an iOS environment.
Long-time iOS/Mac developer Graham Lee helps you rapidly integrate TDD into your existing processes using Apple’s Xcode 4 and the OCUnit unit testing framework. He guides you through constructing an entire Objective-C iOS app in a test-driven manner, from initial specification to functional product. Lee also introduces powerful patterns for applying TDD in iOS development, and previews powerful automated testing capabilities that will soon arrive on the iOS platform. Coverage includes
- Understanding the purpose, benefits, and costs of unit testing in iOS environments
- Mastering the principles of TDD, and applying them in areas from app design to refactoring
- Writing usable, readable, and repeatable iOS unit tests
- Using OCUnit to set up your Xcode project for TDD
- Using domain analysis to identify the classes and interactions your app needs, and designing it accordingly
- Considering third-party tools for iOS unit testing
- Building networking code in a test-driven manner
- Automating testing of view controller code that interacts with users
- Designing to interfaces, not implementations
- Testing concurrent code that typically runs in the background
- Applying TDD to existing apps
- Preparing for Behavior Driven Development (BDD)
The only iOS-specific guide to TDD and unit testing, Test-Driven iOS Development covers both essential
concepts and practical implementation.
Download free code files here
10 of 10 people found the following review helpful
This review is from: Test-Driven iOS Development (Developer's Library) (Paperback)I'd actually talked with Graham briefly after his TDD presentation at the Seattle VTM conference last year, where he'd just about convinced me that TDD might be something other than the development-slowing waste of time I'd previously observed it to be at places that applied it as a management-imposed afterthought, so I had fairly high expectations of the book; and why yes, yes indeed it would be an excellent book even if it wasn't the one and only out there for iOS on the subject -- matter of fact, unconditionally recommended to anyone who wants to be a better iOS programmer!
If you've already got the TDD religion from other platforms, you can jump directly to Chapter 4 "Tools For Testing"; those of us of a more skeptical bent will find reading through Chapters 1-3 an nice gentle progression through demonstrating the value of testing at all through to "How to Write a Unit Test" and how that leads to safely refactorable design.
Said Chapter 4 goes over the Xcode... Read more
4 of 4 people found the following review helpful
Finally, a book on TDD for iOS and OS X,
This review is from: Test-Driven iOS Development (Developer's Library) (Paperback)While I wouldn't call myself a long-time expert, I do know my way around iOS and OS X development, and have been working on my own apps for a couple of years. I've been aware of Test Driven Development (TDD) for a while, have read a number of books on the subject, and can see the benefits of approaching a project in this way. But taking that information and putting it into practice on the Apple toolkit has always proved an issue. The Apple platforms, and Objective-C in particular, are just different enough to the usual TDD environment--Ruby--to make all the other books and tutorials opaque enough that you are never sure if you are doing it `right'.
Which is where this book comes in. It doesn't rely on you knowing anything about the subject, and gently guides you through the concepts of TDD as well as detailed code-driven practice on how to do it, using the built-in Xcode facilities.
You get an introduction on how to test all the `layers' of your app, through the... Read more
3 of 3 people found the following review helpful
Really nice read,
Amazon Verified Purchase(What's this?)
This review is from: Test-Driven iOS Development (Developer's Library) (Paperback)If you already know the basics of TDD, or have been doing it in another language / platform, you probably won't read anything too surprising. If you wanna know how TDD is applied in iOS development, it's definitely your book. If you wanna learn TDD from scratch, I belive it's a very good book for that too, as it covers the very basics of unit testing and test driven development, and goes on to apply TDD on the development of a full app, from beggining to end.
› See all 16 customer reviews...
Online Sample Chapter
Table of Contents
About the Author xiv
1 About Software Testing and Unit Testing 1
What Is Software Testing For? 1
Who Should Test Software? 2
When Should Software Be Tested? 6
Examples of Testing Practices 7
Where Does Unit Testing Fit In? 7
What Does This Mean for iOS Developers? 11
2 Techniques for Test-Driven Development 13
Test First 13
Red, Green, Refactor 15
Designing a Test-Driven App 18
More on Refactoring 19
Ya Ain’t Gonna Need It 19
Testing Before, During, and After Coding 21
3 How to Write a Unit Test 23
The Requirement 23
Running Code with Known Input 24
Seeing Expected Results 26
Verifying the Results 26
Making the Tests More Readable 28
Organizing Multiple Tests 29
4 Tools for Testing 35
OCUnit with Xcode 35
Alternatives to OCUnit 46
Google Toolkit for Mac 46
Continuous Integration 52
5 Test-Driven Development of an iOS App 59
Product Goal 59
Use Cases 60
Plan of Attack 63
Getting Started 64
6 The Data Model 67
Connecting Questions to Other Classes 76
7 Application Logic 87
Plan of Attack 87
Creating a Question 88
Building Questions from JSON 102
8 Networking Code 113
NSURLConnection Class Design 113
9 View Controllers 127
Class Organization 127
The View Controller Class 128
TopicTableDataSource and TopicTableDelegate 133
Telling the View Controller to Create a New View Controller 149
The Question List Data Source 158
Where Next 170
10 Putting It All Together 171
Completing the Application’s Workflow 171
Displaying User Avatars 185
Finishing Off and Tidying Up 189
Ship It! 199
11 Designing for Test-Driven Development 201
Design to Interfaces, Not Implementations 201
Tell, Don’t Ask 203
Small, Focused Classes and Methods 204
Use Is Better Than Reuse 205
Testing Concurrent Code 206
Don’t Be Cleverer Than Necessary 207
Prefer a Wide, Shallow Inheritance Hierarchy 208
12 Applying Test-Driven Development to an Existing Project 209
The Most Important Test You’ll Write Is the First 209
Refactoring to Support Testing 210
Testing to Support Refactoring 212
Do I Really Need to Write All These Tests? 213
13 Beyond Today’s Test-Driven Development 215
Expressing Ranges of Input and Output 215
Behavior-Driven Development 216
Automatic Test Case Generation 217
Automatically Creating Code to Pass Tests 219
Download the sample pages (includes Chapter 1 and Index)
Book + eBook Bundle
Book Price $23.99
eBook Price $8.40
eBook formats included
This book includes free shipping!
This book includes free shipping!
Includes EPUB, MOBI, and PDF
About eBook Formats
This eBook includes the following formats, accessible from your Account page after purchase:
EPUBThe open industry format known for its reflowable content and usability on supported mobile devices.
MOBIThe eBook format compatible with the Amazon Kindle and Amazon Kindle applications.
PDFThe popular standard, used most often with the free Adobe® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discretely watermarking it with your name, making it uniquely yours.
Get access to thousands of books and training videos about technology, professional development and digital media from more than 40 leading publishers, including Addison-Wesley, Prentice Hall, Cisco Press, IBM Press, O'Reilly Media, Wrox, Apress, and many more. If you continue your subscription after your 30-day trial, you can receive 30% off a monthly subscription to the Safari Library for up to 12 months. That's a total savings of $199.