Skip to content

Instantly share code, notes, and snippets.

@seyitcodeit
Created December 24, 2020 09:04
Show Gist options
  • Save seyitcodeit/5e0c58c028aca0ebbf8f3a147470abc8 to your computer and use it in GitHub Desktop.
Save seyitcodeit/5e0c58c028aca0ebbf8f3a147470abc8 to your computer and use it in GitHub Desktop.
Xcode Waiting Extension
extension XCTestCase {
func wait(for duration: TimeInterval) {
let waitExpectation = expectation(description: "Waiting")
let when = DispatchTime.now() + duration
DispatchQueue.main.asyncAfter(deadline: when) {
waitExpectation.fulfill()
}
// I use a buffer here to avoid flakiness with Timer on CI
waitForExpectations(timeout: duration + 0.5)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment