Unit Testing Framework & GUI for Mac OS X and iPhone (GHUnit)
I’ve always wondered why XCode doesn’t have a unit testing GUI like other IDEs, or why the SenTesting framework has to be such a pain to setup, with all its RunScript build phases, shell scripts, octest bundle insanity. After using the GTMTestCase for the iPhone (since SenTesting isn’t supported on the iPhone SDK) I decided to try to re-purpose some of the GTM Unit Testing code into a standalone testing framework and GUI that I could use on both my Mac OS X and iPhone projects.
GHUnit (pronounced \ˈgü-ˈnit\, I guess?), hosted at gabriel/gh-unit, is meant to be installed as a framework (or embedded in your project for iPhone apps), and run as an application in a separate Test target. The idea being that you can run and crash into the XCode debugger directly and utilize all the debugging techniques that you normally use. The test GUI should allow you to see test failures more clearly, view timings / stats and not have to go fishing for the build console window. And an automated way to view stack traces.
Details on how to use the framework are included in the README.

GHUnit Test GUI for Mac OS X App

Unit Test GUI for iPhone App
For the iPhone side, I included a similar GUI that runs the tests in the simulator. Though since frameworks are not supported on the iPhone SDK, you’ll have to embed it in your project, which is a little bit cumbersome. (Any ideas on how to make this easier?)
GHUnit can be used as a standalone test framework (by subclassing GHTestCase), or with your existing SenTestCase tests or GTMTestCase tests.
So far its pretty basic, but I am using it on a couple projects and its been helping my development a bunch and letting me to write tests as I go without completely destroying my workflow or sanity.
Any feedback is appreciated and let me know if you have any problems with the install/embed instructions or in general. Also thanks to the GTM peeps, on which much of this is based.
Maybe the next step is an XCode plugin?
February 22nd, 2009 at 2:42 am
Looks very nice. From the nice standalone test output UI can we/could we rerun individual tests?
February 22nd, 2009 at 11:34 pm
I’ve been thinking about whether its possible to use the Fix & Continue, to edit a test and re-run without having to quit and re-compile? (Am dreaming about some crazy autotest mode.) But I think initially, a quick way to run or re-run a single test case or method would totally be useful.
BTW, started a google group @ http://groups.google.com/group/ghunit
February 23rd, 2009 at 12:38 am
Just noticed the GHUnit.framework headers were missing from the 0.2.6 build. Fixed in 0.2.7.
February 23rd, 2009 at 2:30 pm
[...] is a new unit testing framework for Mac OS X from Gabriel Handford: I’ve always wondered why XCode doesn’t have a unit testing GUI like other IDEs, or why [...]
March 13th, 2009 at 6:30 am
[...] rel=me » Blog Archive » Unit Testing Framework & GUI for Mac OS X and iPhone (GHUnit) (tags: programming osx iPhone testing unit xcode) Posted in del.icio.us | [...]
March 21st, 2010 at 6:38 am
[...] requirements. So I searched for some frameworks to make tests for my Cocoa application. I found GHUnit. A preoject started by Gabriel Handford. The source is available on [...]