I want to delay progression of a test for T seconds, without generating a timeout.
First I tried the obvious:
sleep(5)
XCTAssert(<test if state is correct after this delay>)
But that failed.
Then I tried:
let promise = expectation(description: "Just wait 5 seconds")
waitForExpectations(timeout: 5) { (error) in
promise.fulfill()
XCTAssert(<test if state is correct after this delay>)
}
My XCTAssert()
now succeeded. But waitForExpectations()
failed with a timeout.
This is according to the documentation of XCTest
wait functions saying:
Timeout is always treated as a test failure.
What are my options?