Unit Testing Framework & GUI for Mac OS X and iPhone (GHUnit)
Saturday, February 21st, 2009I’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?
