Created
December 24, 2020 09:04
-
-
Save seyitcodeit/5e0c58c028aca0ebbf8f3a147470abc8 to your computer and use it in GitHub Desktop.
Xcode Waiting Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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