任何人都有一个或两个指向“STAssertThrows”的IOS / OCUnit文档的链接
API doco +如何使用示例
最佳答案
Here are the docs.
用法很简单,说您有方法
-(void)foo {
[NSException raise:NSInvalidArgumentException format:@"always thrown"];
}
然后,该断言将始终通过
-(void)testFoo {
STAssertThrows([obj foo], @"should throw an exception");
}
您可能想改用
STAssertThrowsSpecific
或STAssertThrowsSpecificNamed
,因为如果您仅捕获任何异常,可能会难以捕获bug。关于iphone - IOS/Unit ST AssertThrows-链接到文档和使用示例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8335460/