Skip to content

Instantly share code, notes, and snippets.

@tibr
Created September 18, 2013 12:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tibr/6608259 to your computer and use it in GitHub Desktop.
Save tibr/6608259 to your computer and use it in GitHub Desktop.
SenTestingKit => XCTestCase exception handling
- (void)failWithException:(NSException *)exception
{
NSRange firstColonRange = [exception.reason rangeOfString:@":"];
NSString *filename = [exception.reason substringToIndex:firstColonRange.location];
NSString *secondPart = [exception.reason substringFromIndex:firstColonRange.location + firstColonRange.length];
NSRange lineSeparatorRange = [secondPart rangeOfString:@" "];
NSString *lineString = [secondPart substringToIndex:lineSeparatorRange.location];
NSString *description = [secondPart substringFromIndex:lineSeparatorRange.location + lineSeparatorRange.length];
[self recordFailureWithDescription:description
inFile:filename
atLine:[lineString integerValue]
expected:NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment