Category Archives for TDD

Xcode TDD Kata: Practice with the Bowling Game


February 22, 2016 Update: Added Swift. Refreshed Objective-C too, for latest Xcode.

How do you learn Test Driven Development? I could explain the principles and practices of Xcode TDD, but the question that comes back is, “But what do I actually do in Xcode?”

That’s what the Bowling Game TDD Kata is for. There’s an Objective-C version and a Swift version.

Xcode TDD Kata

Highkick by Pandiyan V, used under CC BY-NC 2.0 / Added text to original

What’s a code kata?

“Kata” is a Japanese martial arts term for choreographed patterns of movement. Also called “forms,” both students and masters practice these detailed patterns over and over, so that the movements can come without thought.

A “code kata” applies this idea to coding. Some use the term to refer to coding puzzles (how would you code this or that) but let’s be faithful to the martial arts metaphor. A code kata is a set of moves, meant to be memorized and practiced until they can flow effortlessly.

So a “TDD kata” is designed to train your TDD muscles. “Uncle Bob” Martin designed the Bowling Game Kata to impart the moves of Test Driven Development. I have taken his presentation and created a version showing these moves in Xcode, using either Objective-C or Swift.

Continue reading

iOS Test Driven Development: Can It Really Work?


Test Driven Development: Does it work for iOS apps?

Short answer: Sure! Here’s an example:

I developed this iOS app using Test Driven Development

Longer answer: “eBay Instant Sale” went live in the App Store two days ago. I can’t share the source code with you, of course. But here’s the unit test coverage:

92% line coverage!

It was written almost entirely using TDD. Sometimes tests weren’t written first (especially the code by a new engineer I couldn’t mentor because I was away). But test first or test last, they got written.

“That’s fine,” you may say, “but what benefit did they have?” If you’ve never done TDD, you haven’t felt the empowerment it brings. Read the following statements twice:

Continue reading