Xcode中的XCTest和异步测试 [英] XCTest and asynchronous testing in Xcode 6
本文介绍了Xcode中的XCTest和异步测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此Apple在Xcode 6的发行说明中说我们现在可以直接使用XCTest进行异步测试。
So Apple said in the release note of Xcode 6 that we can now do asynchronous testing directly with XCTest.
任何人都知道如何使用Xcode 6 Beta 3(使用Objective-C或Swift)?我不想要已知的信号量方法,而是新的Apple方式。
Anyone knows how to do it using Xcode 6 Beta 3 (Using objective-C or Swift)? I don't want the known semaphore method, but the new Apple way.
我搜索了发布的笔记以及更多,但我什么也没找到。 XCTest标头也不是非常明确。
I searched into the released note and more but I found nothing. The XCTest header is not very explicit either.
推荐答案
会话视频很完美,基本上你想做这样的事情
The sessions video is perfect, basically you want to do something like this
func testFetchNews() {
let expectation = self.expectationWithDescription("fetch posts")
Post.fetch(.Top, completion: {(posts: [Post]!, error: Fetcher.ResponseError!) in
XCTAssert(true, "Pass")
expectation.fulfill()
})
self.waitForExpectationsWithTimeout(5.0, handler: nil)
}
这篇关于Xcode中的XCTest和异步测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文