XCTest and asynchronous testing in Xcode 6

后端 未结 4 1223
情深已故
情深已故 2020-11-30 03:32

So Apple said in the release note of Xcode 6 that we can now do asynchronous testing directly with XCTest.

Anyone knows how to do it using Xcode 6 Beta 3 (Using obj

4条回答
  •  我在风中等你
    2020-11-30 04:13

    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)
    }
    

提交回复
热议问题