I'm trying to find an XCT macro that can assert that a method crashes, rather than an exception. For example, setting a nil key on an NSDictionary throws an exception, so you can test this with
XCTAssertThrows([[NSMutableDictionary dictionary] setObject:@"foo" forKey:nil], @"Setting a nil key on an NSMutableDictionary should throw an exception.")
However setting a nil key on NSUserDefaults doesn't seem to throw an exception, it just crashes the code with a line
Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
This looks like an exception breakpoint, but not a throw? Anyway, the following assertion will kill the test suite as noted above.
XCTAssertThrows([[NSUserDefaults standardUserDefaults] setObject:@"foo" forKey:nil], @"Setting a nil key on NSUserDefaults should crash.");