openConnection:

Creatief, technisch en nauwkeurig

GHTestCase templates for Xcode

I’m something of a convert to test-driven development, but putting my beliefs into practice was another story, until I discovered GHUnit. The only downside was that I got bored really fast creating GHTestCase subclasses by hand. So, like a good little developer, I rolled my own Xcode templates.
I’m something of a convert to test-driven development, but so far my beliefs have not been put into practice. It hasn’t been for want of trying -- boy, have I tried, first for PHP then in Xcode, but it’s just been too hard. Apple’s integration of SenTest into Xcode seemed the start of a brand-new test-driven age, but I only ever got it to work for testing frameworks, thanks to Chris Hanson’s helpful articles. Testing Cocoa apps worked -- until I installed the iPhone SDK’s and then everything went south. Maybe there was some Xcode upgrade to blame as well, but the upshot of it all was that my vision of test-driven development heaven turned into crash-driven hell. But then Gabriel came to the rescue, Gabriel Handford that is.

In my desperate googlings I came across several enthusiastic mentions of Handford’s GHUnit. Bitter experience has taught me to disregard these -- people are always enthusing about this or that on development blogs and fora and nine out of ten times these wonderful editors / plugins / kits etc. bring a lot of installation of woes and crashes and very little joy. But anyway, I decided to risk it once more and while GHUnit has not been completely trouble-free, it actually works! Both on Mac OS and iOS. Hurrah!

So, about a year after I resolved to go test-driven, I am now actually doing just that. And in doing that, quickly got bored creating GHTestCase subclasses by hand. So, like a good little developer, I duplicated Xcode’s SentTest templates and created my own GHTestCase templates, based on Gabriel Handford online documentation at http://gabriel.github.com/gh-unit/.

The templates are available in zipped format on the Downloads page or at my Subversion repository at http://www.tweebomen.com/GHTestCase_templates/.

To check out the Mac OS (Cocoa) version directly into the right folder enter the following into your terminal:
svn checkout http://www.tweebomen.com/GHTestCase_templates/MacOS/ /Developer/Library/Xcode/File\ Templates/Cocoa\ Class

To check out the iPhone (Cocoa Touch) version directly into the right folder enter the following into your terminal:
svn checkout http://www.tweebomen.com/GHTestCase_templates/iPhone/ /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File\ Templates/Cocoa\ Touch\ Class