Test Driven Development: Does it work for iOS apps?
Short answer: Sure! Here’s an example:
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:
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:
Xcode unit testing has come a long way for iOS development. How does it measure up? I wrote this post when Xcode 4 came out, but many of the pros & cons still apply. For unit testing, Xcode has come a long way, but there’s still a lot of room for improvement.
Before Xcode 4, I recommended adding third-party unit testing frameworks such as Google Toolbox for Mac (GTM) and GHUnit. But with Xcode 4, the out-of-the-box tools are mostly sufficient. I say “mostly,” because it’s still a mix of the good, the bad, and the ugly. But, mostly good! Read on for a rundown of the pros and cons…
Hello, and welcome to Quality Coding — a place to share tools, tips & techniques for building quality into iOS development.
I’m Jon Reid. By day, I work as a code monkey in Silicon Valley, developing iOS apps at eBay (and of course, everything on this blog is my opinion, not that of my employer, etc., etc.). By night, I watch Dr. Who with my wife and teenage kids, practice electric bass for my faith community… and code for fun, working on tools like OCHamcrest and OCMockito to help me with my work.
I intend to cover topics here ranging from Xcode settings to continuous integration. My expertise lies in Test Driven Development, so expect to see that as a major theme of this blog.
While I’ll share the things I’ve found that help me craft my code, I hope you’ll also do the same — contributing your tools, tips & techniques in the comments. (Play nice, and keep it constructive; I have the delete button.) Also, feel free to contact me to request topics, or just to say hello.
You can keep up-to-date with my latest posts by subscribing. There’s an RSS feed, of course. But subscribe by email, and you’ll receive a free set of Xcode code snippets I wrote to help you write unit tests!
Also, feel free to follow me on Twitter ( @qcoding ).
Ready? OK, here we go!