Question

I'm writing a test method where I want the SUT to throw an exception when under certain conditions. The code looks like this:

- (void) testCantStartTwice
{
    XCTAssertThrows([self.sut start], @"");
}

Now, all is good and the test passes. However, I have Xcode set an Exception Breakpoint for all ObjC exceptions, which is pretty useful when testing out an app in the debugger. As you now, now when I execute my test suite with ⌘U, now it stops at that test and looks like if it's failing, even though it says "Test Succeeded".

Any way of making the breakpoint not stop at that test?

Thanks and all the best

Was it helpful?

Solution

Perhaps you could use a Test Failure Breakpoint instead of an Exception breakpoint when you are testing. The wwdc 2013 video on unit testing outlined a pretty good workflow for inspecting test failures. It essentially said:

  1. Set a Test Failure Breakpoint which will allow you to inspect the conditions that caused the failure.
  2. If needed, set a manual breakpoint earlier in the test and rerun so you can step through the statements leading to the failure as usual.

This isn't really a direct answer, but as far as I know, I don't think there is a way to create exceptions to the exception breakpoint. Hope it helps

OTHER TIPS

I had the same issue and I was looking for solution for 2 hours. Probably we can't do anything with that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top