Skip to content

Instantly share code, notes, and snippets.

@andresilveirah
Created November 3, 2022 16:53
Show Gist options
  • Save andresilveirah/4be4113b5063fe1ceefe6a4663796b10 to your computer and use it in GitHub Desktop.
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.
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