我不知道发生了什么。我在测试中使用的是expectation
,它不会超时。我已经删除了很多测试,现在只剩下:
func testItem() {
let expec = expectation(description: "expection")
wait(for: [expec], timeout: 3.0)
}
而且它不会失败。它只是挂了。有谁知道为什么会这样?
如果使用XCTestCase.expectation(description:)
,将返回的XCTestExpectation
添加到self.expectations
,则应使用waitForExpectations
而不是wait(for:)
。
使用wait(for:)
时,您应该使用XCTestExpectation(description:)
来创建期望。