Saturday February 04, 2012

Unit Testing Cocoa with MacRuby

If you’re writing Mac apps, love the idea behind the Kiwi testing framework, and are feeling a bit brave, check out Steve Masden’s intro to testing your Objective-C code with MacRuby. Steve walks you through setting up your testing target and getting Rspec to run against your objects.

If you were hoping to use this on iOS code, you have a bit more setup to do. You’ll have to create a new Xcode project specific for Mac OSX, because you can’t mix OSX and iOS targets in the same project files. Then, link in your existing model objects and create the MacRuby testing target as Steve describes. In case it wasn’t obvious, you can only test non-iOS specific code using this method. But at least it’s a start!