Find a quick way to see if the monkey manages to leave the application
Try to find out if there is a way to detect from test code if the application has been exited so the test can stop.
To detect if app is currently running or not:
let isRunning = XCUIApplication().running
print("Application is currently running: \(isRunning)")
To detect if app is currently active or not:
if ((FBApplication.fb_active()?.label)! == "YoursAppName") {
// still in app
} else {
// not in app anymore
}
it checks if current active application on screen has proper label - but it requires WebDriverAgentLib to be included in project. It also properly detects stuff like: notification bar overlay on app, control center, etc.
I'm not sure if checking for active app is possible with current XCTest API.
@DagAgren what would you like to achieve in this issue? if application gets crashed/is not running anymore - just finish the tests? as a fail?
Added functionality to return to the app if Monkey exited it accidentally
Thank you!
This solution kind of solved the problem but this solution will start the test even after the test fails.
@singh88 even if continueAfterFailure = true for a test was set?