iOS UITests failed: IDETestOperationsObserverErrorDomain Code=13 - ios

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

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
https://discuss.bitrise.io/t/test-ui-xcode-9/2313

Related

IOS bot error: Early unexpected exit, operation never finished bootstrapping -

I have a question regarding build error that occurs when bots perform UI testing.
When I just run the UI tests, it just works fine. However, whenever I use bots to run the UI tests, there is build error and I keep getting build error saying:
"Early unexpected exit, operation never finished bootstrapping -"
XCode bot error: Early unexpected exit, operation never finished bootstrapping -
Some proposed solution says that I have to skip the APNs.. In my case the alert came up since the application was trying to register of APNS and the
"App Name" would like to enable Notifications alert was displayed. Skipping the APNS registration for UI Tests will prevent the issue from popping again.
How can I confirm that the alerts are causing the problem? I was not able to check it since simulator shows nothing on CI machine when the tests are performed by bot. Also, could you please specify what steps should be taken to skip the APNS registration for UI Tests? I am using iphone 6s simulator.
I have been stuck here forever.
I would really appreciate your help!
Thanks!
The solution that worked for me was to use iphone 6s simulator (iphone 6s or iphone 6s plus). I was using iphone 6 and it caused me a lot of errors including this one.
The actual reason was that APNS registration could not be skipped using iphone 6 simulator whereas it could be skipped using iphone 6s simulator for me (App would like to enable push notification..). After that, addUIInterruptionMonitorWithDescription successfully worked for me!

Run Xcode Server bots in simulator

I have created some Bots to build, analyze and run unit tests, but I have not been able to make it work in a simulator. All integrations always finish with 12 errors, one for every simulated device.
Assertion: Test target MyAppTests encountered an error (The operation couldn’t be completed. (OSStatus error -1712.) If you believe this error represents a bug, please attach the log file at /Library/Developer/XcodeServer/Integrations/Integration-7d62a04eb43957f1d3098c8ffb64cc13/Session-2016-06-22_20:00:39-svEh7I.log)
This same error repeats itself 12 times. I believe it has something to do with the simulators because the tests only pass on the real devices.
Is there some trick that needs to be done for the simulators to work? The bot configuration for devices is to test with All iOS Devices and Simulatos.
Thanks in advance.

iOS UITesting Error

I am trying to run Xcode UITesting on a physical device (iPod), but am getting the error :
Test Target UITests encountered an error (Early unexpected exit,
operation never finished bootstrapping-no restart will be attempted).
The specific line that is triggering the error is :
[[[XCUIApplication alloc] init] launch];
I have noticed that the UITesting app does not launch on the device, instead on the test target app is launching, which I assume is the issue. Any ideas on how to fix this?
I was able to fix this bug by altering the build settings, specifically bundle loader. I removed build/Debug-iphoneos/MY_APP.app/MY_APP from debug and build/Release-iphoneos/MY_APP.app/MY_APP. I then added a couple additional compile sources and was able to get the UITesting to function again.

UI Tests no longer working on Xcode 7.3

I have a set of XCUITests that run with our iOS app. They used to run fine on Xcode 7.2.1, but upgrading to 7.3 causes tests to fail in the "Set Up -> Wait for app to idle" phase with the following error:
UI Testing Failure - Failed to perform AX action for monitoring the animations of <XCUIApplicationProcess: 0x7f82450288c0 [appName here] (25670)>, error: Error -25204 performing AXAction 2043
This failure is seen on every single UI test, both on bots and when running locally.
Has anyone else seen this or have any workarounds?
In case anyone still has this issue - for me it was activating the Optimizely framework that caused this error. Disabling the framework when running XCUITest solved it for me.
Note to self: Don't have code that crashes your app on purpose while tests are trying to run. D:
Basically there was a call to terminate the app within the launch phase of the app for a certain scheme (in our case, the TEST scheme). Be thorough in checking what the app is doing when it launches for testing, because there might be errant behavior.

Simple XCTest for UITest is failing all the time?

I start a new project from File -> New -> project
I add a button to ViewController.
I open UITest folder which created by xcode by default. Run the test code.
It fails:
2016-03-16 12:57:09.191 XCTRunner[3511:150419] Continuing to run tests in the background with task ID 1
t = 10.18s Assertion Failure: UI Testing Failure - Failed to background test runner.
/Users/Bernard/Desktop/ExampleTestApplication/ExampleTestApplicationUITests/test2.m:27: error: -[test2 testExample] : UI Testing Failure - Failed to background test runner.
2016-03-16 12:57:12.789 XCTRunner[3511:150419] *** Terminating app due to uncaught exception '_XCTestCaseInterruptionException', reason: 'Interrupting test'
Now I add a break point as follow:
Now test is successful! Anyone can explain the reason?
I was also facing same issues and none of the available solutions worked for me. Issue was not letting app to attach to the simulator itself.
I checked the log and saw that i did a mistake in code while locating the element. for Predicate instead of BEGINSWITH i wrote STARTSWITH and this was stopping the app to get attached.
So check your logs in the test report to get the issue.
I was getting this error happening when the iOS simulator was already launched (which may not necessarily mean you can see it in the OS X dock). You can check the state of the various simulators using the simctl command.
I.e.
xcrun simctl list devices
Then, ensure that any devices listed as "Booted" are shutdown:
xcrun simctl shutdown <device-udid-here>
Then, try running your UI tests again.

Resources