当我想在xCode 6中注册异步单元测试的期望时,我使用什么语法?谷歌上还没有什么能轻易搜索到这个话题的东西,出现的东西都是用Swift写的。我在找目标-C的例子
发布于 2014-10-08 09:31:31
我找到了肖恩McCune:Asynchronous Testing With Xcode 6的一篇很好的博客文章。
对于目标-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);
}
}];
}我建议阅读他的帖子以作进一步的解释。
https://stackoverflow.com/questions/25165929
复制相似问题