Test UI xcode 9

Hi,
I’m trying to run tests with bitrise new stack, Xcode 9 and I have this error:
Failed to receive completion for <XCDeviceEvent:0x6000004503b0 page 12 usage 64 duration 0.01s within 30.0s

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

It’s just happening for my test UI, test Unit works fine…
Sometimes the build passed :confounded:

Can anyone help me ?

Hi @appaloosa.project,

Does it happen every time? Does a rebuild help?

Also, how do you run the test? With our Xcode Test step?

Can you please copy paste the whole log of the step which fails?

Thanks for your answer,

I am running with Xcode and bitwise CLI, both work. :sweat:

full log with error:

2017-07-19 01:37:52.240 mobilestoreUITests-Runner[5785:24454] Running tests...
objc[5785]: Class PLBuildVersion is implemented in both /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11f629998) and /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 10.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11f44b880). One of the two will be used. Which one is undefined.

Unexpected failure with no current test or suite:
	Failed to receive completion for <XCDeviceEvent:0x6000004503b0 page 12 usage 64 duration 0.01s within 30.0s

2017-07-19 01:38:53.893 xcodebuild[4699:21318] Error Domain=IDETestOperationsObserverErrorDomain Code=13 "Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-C46935FE-354E-455D-91CE-9E9E52F13308/mobilestoreUITests-C5138FF5-0569-465D-A957-8A9CF15AB269/Session-mobilestoreUITests-2017-07-19_013729-Jc6p9n.log" UserInfo={NSLocalizedDescription=Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-C46935FE-354E-455D-91CE-9E9E52F13308/mobilestoreUITests-C5138FF5-0569-465D-A957-8A9CF15AB269/Session-mobilestoreUITests-2017-07-19_013729-Jc6p9n.log}
error: /Users/vagrant/Library/Developer/Xcode/DerivedData/mobilestore-azsghfjtffpqxidrakapqsjbiqza/Build/ProfileData/54CEF7D1-B1AE-4E86-A176-C938FF4CF078/5785.profraw: Invalid instrumentation profile data (file header is corrupt)

Testing failed:
	Test target mobilestoreUITests encountered an error (Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-C46935FE-354E-455D-91CE-9E9E52F13308/mobilestoreUITests-C5138FF5-0569-465D-A957-8A9CF15AB269/Session-mobilestoreUITests-2017-07-19_013729-Jc6p9n.log)
** TEST FAILED **

xcode test exit code: 65
xcode test failed, error: exit status 65

Just to be sure, it works locally on your Mac with Bitrise CLI, but does not (the same bitrise.yml) work on bitrise.io ?

If that’s the case (and you’re sure you run the same bitrise.yml on bitrise.io too), can you please:

  1. Follow this guide How to debug your build locally / "It works on my Mac/PC but not on bitrise.io" (make sure to start with a clean git clone into a new directory!! + also that you test with a clean iOS Simulator, as described in the guide!)
  2. If that wouldn’t help, send us the build’s bitrise.io URL in email / through the onsite chat

I am running into the same issue with Fastlane’s scan. As mentioned above, sometimes it passes… sometimes it doesn’t.

While making this comment I’ve ran it 3 times on bitrise locally with the following result:
Pass: 2
Fail: 1

Xcode Version: 9
Fastlane :
version 2.61.0
scan:
devices: [‘iPhone 8’]


	 Executed 2 tests, with 0 failures (0 unexpected) in 0.741 (0.743) seconds
2017-10-12 09:08:57.869 xcodebuild[2089:9046] Error Domain=IDETestOperationsObserverErrorDomain Code=13 "Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-BA4A903B-9124-4C2F-8D12-25627A7176C1/Exelon-SealsUITests-82D1BF21-24D7-4192-B119-F71BB46851A9/Session-Exelon-SealsUITests-2017-10-12_090710-5zELAK.log" UserInfo={NSLocalizedDescription=Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-BA4A903B-9124-4C2F-8D12-25627A7176C1/Exelon-SealsUITests-82D1BF21-24D7-4192-B119-F71BB46851A9/Session-Exelon-SealsUITests-2017-10-12_090710-5zELAK.log}
Testing failed:
Test target Exelon-SealsUITests encountered an error (Failed to background test runner. If you believe this error represents a bug, please attach the log file at /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/com.apple.dt.XCTest/IDETestRunSession-BA4A903B-9124-4C2F-8D12-25627A7176C1/Exelon-SealsUITests-82D1BF21-24D7-4192-B119-F71BB46851A9/Session-Exelon-SealsUITests-2017-10-12_090710-5zELAK.log)
** TEST FAILED **
[09:09:00]: Exit status: 65

New findings:

It for sure fails if being ran on a new/clean simulator(Erase All Content and Settings…), but if the application is already installed on the simulator, the tests pass as expected.

Even better findings:
When the application is ran on a clean simulator, the typical notification alert appears: " Would like to Send you Notifications"(should probably disable this for testing), and this causes the application to encountered an error (Failed to background test runner.

If I comment out the notification code in the app delegate, it allows the test to pass.

2 Likes

Indeed, I believe you found the cause of the issue, that your app presents a popup at first run. Let us know if you have any questions, the solution you wrote seems to be :+1: