Tuesday, November 15, 2011

Setting Up GHUnit in XCode 4

If you're looking for a hand held step by step walk through in getting GHUnit set up and configured in XCode 4, then you really need to watch this video put up by Robert van Loghem from Xebia. It does an excellent job at conveying exactly what you need to do, and where you need to go to grab additional external resources to get things up and running.

If you pop open GHUnitIOSTestMain.m, you'll notice a commented out section right at the top of the main method that lists some environment variables that can be useful and helpful in debugging. One that isn't listed though is GHUNIT_AUTORUN. Setting this to a value of YES will cause your tests to run automatically whenever you run them in the simulator, or if you choose, on your device. In XCode 4 you can set environment variables for a target by going to Product --> Edit Scheme... Selecting that should open up a view like the following, which is where you can add this setting. Make sure you're setting it for the application that has your tests in it.

It saves the step of hitting the "run" button in the UI, which is nice.

I found that useful little bit on Brett Schuchert's video series about doing TDD in iOS (specifically the one titled "Integer RPN Calculator: Setting Up The Environment"). I recommend giving the series a watch as he has some good information in it, and you get to see how he works. The series is based in XCode 3 so what you see won't exactly match up with what you see in XCode 4, but the more familiar you become with the environment the more adept you'll be a tracking things down.

No comments:

Post a Comment