So up ’til now there have been some options for doing unit testing on your iPhone applications, but they’ve involved enough effort and annoyance that, well, they just aren’t used as often as respectable programming practice would imply. Not around here, anyways; more like idly kick the idea around, grumble “Why hasn’t Apple seen fit to integrate OCUnit as nicely as in desktop Cocoa projects?” and continue on with non-test driven development.
Well, turns out that it’s actually been there since SDK 2.2, in the simulator at least, and rumour has it that device support may be coming soon! So, it behooves us to get started now, as even running unit tests in the simulator is a useful exercise, yes?
iPhone Unit Testing at the OCUnit authors’ website is a quick introduction with sample project.
iPhone Unit Testing with OCUnit at 6Tringle is a great detailed tutorial.
And at the mothership, read the introduction, walkthrough, Unit Testing Guide, and otest and RunTargetUnitTests documentation to get a handle on just why it’s so nice to be able to take advantage of Xcode’s support!
And on a not completely unrelated note, here’s a project on Google Code called Bromine that aims to let you create automated interface tests:
It maps your entire application to XML structures so you can access your views via xpath and verify values, scroll tables, simulate touches, edit text and more.
This project was inspired by Matt Gallagher’s article (Cocoa with Love: Automated user interface testing on the iPhone) which brings, among others, the base technique for this project: simulate touch.
That looks worth working into as well for a complete testing strategy, indeed.
