When it comes to TDD in Objective-C, AppCode is superior to Xcode. Watch, I’ll show you.
Remember my iOS Model-View-Controller TDD screencast? Eric Baker took it a few extra steps. He made an excellent follow-up screencast that demonstrates:
Without further ado… heeere’s Eric!
I thought about posting my thoughts about the tools Eric demonstrates… but I didn’t want to dominate the conversation. What do you think?
I will share this much up-front: Look for another post about how this screencast changed my mind about dot notation!
The UIViewController TDD screencast ended with all the code in the view controller. Unfortunately, this is where many iOS programmers leave things! In part 2, we pick up from there and TDD to extract a model class, which the controller observes. You’ll see it evolve into true Model-View-Controller, driven by unit tests.
In particular, you’ll see how to TDD:
Questions? Continue Reading…
Is TDD worth the effort? Andy Dwelly tried applying my TDD screencasts to his iOS coding. Here’s what he writes in Some notes on Test Driven Development:
At first progress was almost painfully slow.
Yup. It seems like there’s a lot to learn. The real barrier, I think, is that there is a lot to unlearn. And so, when you first get started with Test Driven Development, your productivity will take a big hit. This is normal! But if you’re willing to press through the learning curve, your productivity will increase again — in ways you may not have experienced before… Continue Reading…
This screencast focuses on the question I get the most: “Do you do test-driven development for view controllers?” It’s clearly a roadblock for many people. This screencast should remove that roadblock.
It also answers the question, “Is it worth doing?”
Any questions? Continue Reading…
My first screencast! It was sparked by a Stack Overflow question that said, “All the examples of unit testing I read about seem to be extremely simple and trivial.” The question asks how to write unit tests for a piece of sample code. What’s interesting about this problem is that it uses NSUserDefaults.
Any questions? I’d love to hear your experience with this screencast. Continue Reading…
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 Kata is for. (Download PDF.)
“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. “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 Objective-C with Xcode 4. Continue Reading…
Test driven development: Does it work for iPhone apps?
Short answer: Sure!
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:
Preventing bugs isn’t a TDD goal. It’s more like a side effect.
It was written almost entirely using TDD. Sometimes tests weren’t written first (especially for 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…