如何在xCode 6中使用期望设置异步单元测试?

Ale*_*one 5 unit-testing asynchronous objective-c xcode6

当我想在xCode 6中注册异步单元测试的期望时,我会使用什么语法?谷歌没有什么可以轻易搜索到这个主题,而且显示的内容是用Swift编写的.我正在寻找Objective-C的例子

reg*_*ian 6

我找到了一篇由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);
        }
    }];
}
Run Code Online (Sandbox Code Playgroud)

我建议阅读他的帖子进一步解释.