Search code examples
iosxcodejenkinsxcodebuildxcode-ui-testing

iOS UITests failed: IDETestOperationsObserverErrorDomain Code=13


I am running an AppUITests for an iOS app from Jenkins build script. Unit tests (AppTests) running fine but AppUITests are failed because of the below issue. How can I resolve this issue?

09:19:53.506 XCTRunner[22911:77924] Failed to background test runner within 30.0s. 09:19:53.507 xcodebuild[22835:77541] -[IDETestOperationCoordinator testRunnerSession:initializationForUITestingDidFailWithError:] 09:19:53.507 XCTRunner[22911:77924] Calling completion. 09:19:53.507 xcodebuild[22835:77541] Test operation failure: Failed to background test runner. 09:19:53.507 xcodebuild[22835:77541] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=13 "Failed to background test runner." UserInfo={NSLocalizedDescription=Failed to background test runner.} didCancel: 1


Solution

  • I had the same issue in our app. It was caused by a permission alert displayed on launch (APN in this case, but it's likely to be the same for any other alert).

    Steps to reproduce

    • use an app which will display a permission alert on launch
    • make sure the simulator is clean (in order to show the alert)
    • run all Tests

    Result

    • app launches, shows the alert and runs the (normal) Tests just fine
    • BUT when coming to UITests, the simulator will stay black and after a short while, it fails with following error:

    Error Domain=IDETestOperationsObserverErrorDomain Code=13 "Failed to background test runner.

    Solution

    Run the UITests before the normal Tests (just change the order in edit scheme => Test => Info)

    Notes:

    • Maybe you have to make sure, the UITests will handle the alert by using XTests addUIInterruptionMonitor method. Or otherwise it could be possible the (normal) Tests will fail the same way (didn't test this scenario).
    • If you really don't want to run the UITests first, you could add an additional UITest target, which is run first, and just handles the alert. Then you should be able to run the (normal) Tests followed by your UITests.

    Related