I've just started writing tests for my iOS app, I'm using Xcode4 and OCUnit. I'm now writing a test for a piece of code that should throw an exception if a static variable has already been assigned to, like this:
NSAssert(controllerInstance == nil, @"another controller is already in use!");
In my test I use STAssertThrows
to check that the above code throws an error if the instance already exists. The problem is that this test fails with:
*** Assertion failure in (reference to row with NSAssert)
So the test is failing even though the behavior is exactly the one I want. But shouldn't STAssertThrows
catch this? Maybe I shouldn't use NSAssert together with STAssertThrows
in this way?