2

We're trying to debug some unit tests which are randomly failing. We believe this is because the codebase improperly mixes UI interaction as part of unit testing (i.e. instantiates ViewControllers while firing off service requests that update them.)

I'm trying to go through and clean this up, but I keep getting things like this...

2019-01-15 11:05:37.500086-0500 [NAME REDACTED][78259:9742813] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete section 1, but there are only 0 sections before the update'

The trouble is we have no idea which test (or tests) is causing the table to be updated. Worse, we don't even know which table it is! The call stack improperly hangs on a WaitForExpectations call in a unit test which tests service-calls and responses and which doesn't even reference, let alone instantiate anything to do with the UI.

Our guess is its happening from an earlier test that fires up some UI component which internally fires off some request, and the response comes back long after the original unit test was finished. That would explain why it's breaking in a completely-unrelated test. But it's just a guess because we're not sure how to actually break on the line that's causing the true, underlying exception.

So as the title says, how can you break on a specific exception? I've tried symbolic breakpoints to no avail, and the regular All Exceptions breakpoint catches way too much to the point of being more intrusive than useful. We only want to break on that one exception. Is it possible?

Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286

0 Answers0