Skip Navigation
List Price: $54.86

Rent Book

Select for Price
Add to Cart Free Shipping
There was a problem. Please try again later.

New Book

We're Sorry
Sold Out

Used Book

We're Sorry
Sold Out

Test-driven Ios Development,9780321774187

Test-driven Ios Development

by
Edition: 1st
Format: Paperback
Pub. Date: 4/9/2012
Publisher(s): Addison-Wesley Professional
Availability: This title is currently not available.

Summary

As iOS apps become increasingly complex and business-critical, developers must adopt more effective processes for creating and testing them. Test-driven development (TDD) is one of today's most powerful best practices for improving development and ensuring superior code quality. Now, for the first time, there's a complete guide to successfully implementing TDD and unit testing in iOS environments. Long-time iOS and Macintosh developer Graham Lee shows how these techniques can be effectively integrated into existing processes; how to use Apple and third-party tools to implement them, and how to maximize the value of testing without slowing down development. A complete case study example guides developers through constructing an entire iOS app in a test-driven manner. Lee shows how to use TDD to overcome many common iOS development challenges, and how to test app components including models, domain logic, and view controllers. Building on his example, he identifies powerful patterns for applying TDD in iOS environments, and previews powerful automated testing capabilities that have recently come to the iOS platform or are expected to arrive soon. The only iOS-specific book on TDD and unit testing, Test-Driven iOS Development covers both essential concepts and practical implementation. From start to finish, it reflects the realities working iOS developers face - and helps them write code that's clean and robust enough to meet virtually any requirement

Author Biography

Graham Lee's job title is “Smartphone Security Boffin,” a role that requires a good deal of confidence in the code he produces. His first exposure to OCUnit and unit testing came around six years ago, as test lead on a GNUstep-based server application. Before iOS became the main focus of his work, Graham worked on applications for Mac OS X, NeXTSTEP, and any number of UNIX variants.

 

This book is the second Graham has written as part of his scheme to learn loads about computing by trying to find ways to explain it to other people. Other parts of this dastardly plan include speaking frequently at conferences across the world, attending developer meetings near to his home town of Oxford, and volunteering at the Swindon Museum of Computing.

 

Table of Contents

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

NSURLConnection Class Design    113

StackOverflowCommunicator

Implementation    114

Conclusion    125

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

Encapsulation    205

Use Is Better Than Reuse    205

Testing Concurrent Code    206

Don’t Be Cleverer Than Necessary    207

Prefer a Wide, Shallow Inheritance Hierarchy    208

Conclusion    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

Conclusion    220

Index    221

An electronic version of this book is available through VitalSource.

This book is viewable on PC, Mac, iPhone, iPad, iPod Touch, and most smartphones.

By purchasing, you will be able to view this book online, as well as download it, for the chosen number of days.

A downloadable version of this book is available through the eCampus Reader or compatible Adobe readers.

Applications are available on iOS, Android, PC, Mac, and Windows Mobile platforms.

Please view the compatibility matrix prior to purchase.

Visa
Mastercard
American Express
Comodo
McAfee