How to detect if iOS app is running in UI Testing mode

I’ve been researching this myself and came across this question. I ended up going with @LironYahdav’s first workaround: In your UI test: – (void)setUp { [super setUp]; XCUIApplication *app = [[XCUIApplication alloc] init]; app.launchEnvironment = @{@”isUITest”: @YES}; [app launch]; } In your app: NSDictionary *environment = [[NSProcessInfo processInfo] environment]; if (environment[@”isUITest”]) { // Running in … Read more

Xcode UI test – UI Testing Failure – Failed to scroll to visible (by AX action) when tap on Search field “Cancel’ button

I guess here “Cancel” button returns false for hittable property, that is preventing it from tapping. If you see tap() in documentation it says /*! * Sends a tap event to a hittable point computed for the element. */ – (void)tap; It seems things are broken with Xcode 7.1. To keep myself (and you too … Read more

Is there a way to reset the app between tests in Swift XCTest UI?

You can add a “Run Script” phase to build phases in your test target to uninstall the app before running unit tests against it, unfortunately this is not between test cases, though. /usr/bin/xcrun simctl uninstall booted com.mycompany.bundleId Update Between tests, you can delete the app via the Springboard in the tearDown phase. Although, this does … Read more