Created
November 3, 2022 16:53
-
-
Save andresilveirah/4be4113b5063fe1ceefe6a4663796b10 to your computer and use it in GitHub Desktop.
I'm not sure the app's threads are suspended like `sleep`, but the code in this gist will pause for a bit before relaunching the app for UI testing.
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
func waitAndRelaunch(timeout: TimeInterval = 0) { | |
let waitingExpectation = XCTestExpectation(description: "Wait a bit") | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(Int(timeout))) { | |
waitingExpectation.fulfill() | |
} | |
self.wait(for: [waitingExpectation], timeout: timeout + 1) | |
self.app.relaunch() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment