What’s Next?

We’ve reached the end of this book. You’ve grown in your unit testing. You’ve improved your refactoring skills. The next logical step is to begin mastering test-driven development.

Here are some next steps for you to take. First, try to use TDD the next time you need a piece of functionality that doesn’t use UIKit. This is what we did for our time-of-day greeter.

Then combine TDD with the iOS testing tips and techniques in Part II. You might start with the following exercise: Use TDD to make an iOS app that shows two buttons. Tapping either button will push another view controller, showing a label. The text of the label depends on which button you tapped.

After this, use TDD to make the next new view controller in your actual code. A test-driven approach will lead you to identify any difficult dependencies right away. Sketch out a rough design on a whiteboard, but allow the actual design to emerge.

It shouldn’t take long before you begin to experience the benefits of TDD. There is, of course, the big benefit of unit testing—safety. But TDD adds to this by making testability a requirement. You’ll still puzzle over “How can I test this,” but you’ll ask that question first instead of at the end when it’s too late. Testability leads to better designs where the components are more modular. This—and continuously asking, “How can I clean this up?”—will lead to code that’s easier to change. The end result is that making changes will become faster.

Don’t become discouraged if you find TDD hard at first. You are learning how to code backward. You have taken the first steps in a journey of discovery that never stops. Get help along the way to accelerate your progress, and have fun!