gpt4 book ai didi

iphone - IOS/Unit ST AssertThrows-链接到文档和使用示例

转载 作者:行者123 更新时间:2023-12-01 18:01:55 24 4
gpt4 key购买 nike

任何人都有一个或两个指向“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");
}

您可能想改用 STAssertThrowsSpecificSTAssertThrowsSpecificNamed,因为如果您仅捕获任何异常,可能会难以捕获bug。

关于iphone - IOS/Unit ST AssertThrows-链接到文档和使用示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8335460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com