How to solve 'Test runner exited before starting test execution' error for iPhone Devices
We have E2E Testing running on the CI on the iPhone devices.
The script performs the following steps -
- Build the Test runner app from code.
- Extracts the app file from the IPA.
- Re-codesign the app with the required Provision Profiles.
- Creates a
- Uses the
xcodebuildcommand like the following to run the test -
xcodebuild -sdk iphoneos -destination id=<device_id> -xctestrun <path_to_xctestrun_file> -resultBundlePath <path_to_test_bundle_file> test-without-building -only-testing:E2ETestsBundle.xctest/<test_filter>
- The above command installs the runner and target app into the device and starts executing the test.
The apps get installed and uninstalled at each run during a single execution.
During the execution, the
xcodebuild CLI tool, suddenly loses connection to the device and is not able to install the apps into the device and then results in the following error -
Testing failed: E2ETestsBundle.xctest: E2ETestsBundle-Runner encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: Test runner exited before starting test execution. If you believe this error represents a bug, please attach the log file at /var/folders/1r/0xlnbmzd0yj3m_cc7p95yb4r0000gn/T/tmpl7d9p1s6/testResults.bundle/Staging/1_Test/Diagnostics/E2ETestsBundle-Configuration-Test Scheme Action-Iteration-1/E2ETestsBundle/Session-E2ETestsBundle-2022-04-13_205520-muaMCx.log)) ** TEST EXECUTE FAILED **
Points to note -
xcodebuildCLI tool will keep on failing with the error once it occurred until recovered.
- Even while the xcodebuild is in a failed state, the devices are still accessible via Xcode IDE and other CLI tools like libimobiledevice and are able to install both the test runner and target applications.
- This is occurring intermittently across all devices models and across subversions of iOS 14 and 15.
- The only way to recover is to reboot the device.
- Even after a reboot, the devices start facing this exception again after a few days of execution.
As we can’t keep on rebooting the device every time before execution, we need a solution to fix this problem. Any help would be appreciated!!