views:

59

answers:

2

I'm using Xcode 3.2.2 and the built in OCUnit test stuff. One problem I'm running into is that every time I do a build my unit tests are run, even if the build failed. Let's say I make a syntax error in one of my tests. The test fails to compile and the last successful compilation of the unit tests are run. The same thing happens if one of the dependent targets fail to build - the tests are still run. Which is obviously not what I want.

How can I prevent the tests from running if the build fails? If this is not possible then I'd rather have the tests never run automatically, is that possible? Sorry if this is obvious, I'm an Xcode noob. Should I be using a better unit testing framework?

+1  A: 

The answer is to dump OCUnit and use GHUnit which is about a million times better: http://github.com/gabriel/gh-unit

mhenry1384
+1  A: 

All you need to do is make the script that runs the unit tests dependent on your test bundle having been built. To do this:

In your Targets group expand your unit test bundle and Get Info on the Run Script.

On the general tab click the + button for the Input Files and enter:

$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_PATH)
martinB
+1 I'll take your word for it. I'm pretty happy with GHUnit so I won't be switching back to verify this works.
mhenry1384