当我想在xCode 6中为我的异步单元测试注册期望值时,我应该使用什么语法?目前在谷歌上没有相关的易于搜索的内容,而出现的内容都是用Swift编写的。我正在寻找Objective-C的示例。
当我想在xCode 6中为我的异步单元测试注册期望值时,我应该使用什么语法?目前在谷歌上没有相关的易于搜索的内容,而出现的内容都是用Swift编写的。我正在寻找Objective-C的示例。
我找到了一篇关于it技术的不错博客文章,作者是Sean McCune: 使用Xcode 6进行异步测试。
对于Objective-C,他给出了以下示例:
- (void)testWebPageDownload
{
XCTestExpectation *expectation =
[self expectationWithDescription:@"High Expectations"];
[self.pageLoader requestUrl:@"http://bignerdranch.com"
completionHandler:^(NSString *page) {
NSLog(@"The web page is %ld bytes long.", page.length);
XCTAssert(page.length > 0);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) {
if (error) {
NSLog(@"Timeout Error: %@", error);
}
}];
}