Xcode 5 and Test-Driven iOS Development
With Xcode 5, Apple is adding some great tools to make it easier to write unit tests and have Continuous Integration run those tests often.
Xcode 5 is shipping with Apple’s new XCTest framework, which is based on the OCUnit framework that has been shipping with Xcode for a while. Xcode 5 and XCTest make it much easier to see which tests are passing or failing, as well as allowing you to run individual unit tests again with a single button press.
Also new with OS X Mavericks Server is Xcode Server. Xcode Server makes it easy to run Continuous Integration on your applications by creating “bots”. These “bots” regularly build your application and can run all it’s tests on multiple devices.
All of this new stuff is useless if you don’t have any tests to run. If you haven’t already starting doing Test-Driven Development, now is a great time to start. Maybe you’ve used Test-Driven Development before, but you’re not sure where to begin with iOS. I highly recommend picking up a copy of “Test-Driven iOS Development” by Graham Lee.
Most TDD books are intended for Java developers, but this one is focused on building a real iOS application that consumes the Stack Overflow API. It’s been extremely helpful for me to have a real example of Test-Driven iOS Development to follow along with. The book covers almost everything you’re wondering about, including testing network calls and View Controllers. It even has some good advice at the end about how to begin using TDD even when you have an existing application that has no tests.
Start refactoring your code without fear, go get this book.
Check out this book on the iBookstore: “Test-Driven iOS Development” by Graham Lee