How to cause Xcode unit-tests to fail and not crash in case of an uncaught exception?

1.1k Views Asked by At

I'm using the built-in Unit Testing mechanism in Xcode (OCUnit/SenTest).

I find it very upsetting that whenever there's an exception thrown during a test, instead of moving on and running the next tests, Xcode crashes the run (stopping the debugger on the line of the thrown exception, and marks the tests as successful after crashing!).

Is there any way of making the test target just mark the test that raised an exception as failed and move on?

BTW, please don't bother telling me to move to GHUnit, I know it exists but I'm stubborn and want to work with something that is built-in to Xcode.

3

There are 3 best solutions below

0
On BEST ANSWER

Turns out as @Jon Reid said, this was a bug in iOS simulator, but it was fixed for iOS 5.0 simulator!

So it seems the solution is simply to run the tests only on the iPad/iPhone 5.0 simulator on Xcode 4.2

0
On

As far as my knowledge there is no option like that.

1
On

This isn't an issue with OCUnit, but is an open bug with the iOS simulator: http://openradar.appspot.com/8081169

You'd have the same problem with GHUnit.

Unfortunately, this bug severely hinders OCMock, which is written to throw exceptions when an expectation isn't met.