0

我不知道是怎么回事。我expectation在测试中使用了一个,它不会超时。我已经删除了很多测试,现在我只剩下:

func testItem() {
    let expec = expectation(description: "expection")
    wait(for: [expec], timeout: 3.0)
}

而且它不会失败。它只是挂起。有谁知道为什么会发生这种情况?

4

1 回答 1

3

如果您正在使用XCTestCase.expectation(description:),它会将返回的内容添加XCTestExpectationself.expectations,您应该使用waitForExpectations而不是wait(for:)

使用时,wait(for:)您应该使用 XCTestExpectation(description:).

于 2020-04-07T08:31:40.233 回答