Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.
This is the Rough Cut version of the printed book.
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
The only iOS-specific guide to TDD and unit testing, Test-Driven iOS Development covers both essential
concepts and practical implementation.
Dedication v
Preface xii
Acknowledgments xiv
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
Refactoring 32
Summary 34
4 Tools for Testing 35
OCUnit with Xcode 35
Alternatives to OCUnit 46
Google Toolkit for Mac 46
GHUnit 47
CATCH 48
OCMock 50
Continuous Integration 52
Hudson 53
CruiseControl 57
Summary 58
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
Topics 67
Questions 73
People 75
Connecting Questions to Other Classes 76
Answers 81
7 Application Logic 87
Plan of Attack 87
Creating a Question 88
Building Questions from JSON 102
8 Networking Code 113
