Reputation: 111
During running iOS Tests via fastlane (scan) there are random problems with the tests' stability. The error visible in logs:
Lost connection to the application (pid XXXX).
<unknown>:0
Does anyone know what may be a reason of losing connection to the application?
My tests are implemented in classes and each of them inherits the BaseTest class, the app is launched in the following way:
import XCTest
class BaseTest: XCTestCase {
let app = XCUIApplication()
...
override func setUp() {
continueAfterFailure = false
app.launch()
...
}
override func tearDown() {
super.tearDown()
let screenshot = XCUIScreen.main.screenshot()
let fullScreenshotAttachment = XCTAttachment(screenshot: screenshot)
fullScreenshotAttachment.lifetime = .deleteOnSuccess
add(fullScreenshotAttachment)
app.terminate()
}
...
}
There are also Page Object classes implemented, each of them inherits the BaseScreen:
import XCTest
class BaseScreen {
let app: XCUIApplication = XCUIApplication()
}
extension BaseScreen {
func findAll(_ type: XCUIElement.ElementType) -> XCUIElementQuery {
return app.descendants(matching: type)
}
}
Tests are run via fastlane as follows:
lane :ui_tests do
# Performing UI Tests
scan(
clean: true,
reinstall_app: true,
app_identifier: "XXX",
workspace: workspace,
scheme: "uiTests",
devices: devicesUITests,
code_coverage: true,
open_report: false,
output_style: "rspec",
output_types: "html",
output_directory: "./build/DerivedData/test_output",
result_bundle: "true",
buildlog_path: "./XXX",
xcargs: "OTHER_SWIFT_FLAGS=\"-Xfrontend -debug-time-function-bodies\" SWIFT_OPTIMIZATION_LEVEL=\"-Owholemodule\"",
derived_data_path: "./build/DerivedData"
)
puts("Generating Test Report ...")
sh('xchtmlreport -r ../build/DerivedData/test_output')
puts("Test Report Successfully generated")
end
I am also using UIInterruptionMonitor for alerts, this may also be relevant.
Edited: There is the following fragment a the end of StandardAndStandardError.txt:
2019-03-15 12:23:49.511 XXX[35711:8931440] *** Accessing the keyManager while not available yet
2019-03-15 12:23:49.511 XXX[35711:8931440] *** Accessing the keyManager while not available yet
2019-03-15 12:23:50.065 XXX[35711:8931461] Cannot find executable for CFBundle 0x7fd7f74336e0 </.../Library/Developer/CoreSimulator/Devices/.../data/Containers/Bundle/Application/.../XXX.app/Frameworks/DJISDK.framework/DJIFlySafe.bundle> (not loaded)
2019-03-15 12:23:50.073 XXX[35711:8931465] Cannot find executable for CFBundle 0x7fd7f75015d0 </.../Library/Developer/CoreSimulator/Devices/xxx/data/Containers/Bundle/Application/xxx/XXX.app/Frameworks/DJISDK.framework/SDKSharedLib.bundle> (not loaded)
CoreData: annotation: Failed to load optimized model at path '/.../Library/Developer/CoreSimulator/Devices/xxx/data/Containers/Bundle/Application/xxx/XXX.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: annotation: Failed to load optimized model at path '/.../Library/Developer/CoreSimulator/Devices/xxx/data/Containers/Bundle/Application/xxx/XXX.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
CoreData: annotation: Failed to load optimized model at path '/.../Library/Developer/CoreSimulator/Devices/xxx/data/Containers/Bundle/Application/xxx/XXX.app/GoogleMaps.bundle/GMSCacheStorage.momd/StorageWithTileProto.omo'
xxx(35711,0x7000060f9000) malloc: Heap corruption detected, free list is damaged at 0x6000009754a0
*** Incorrect guard value: 4416955976
xxx(35711,0x7000060f9000) malloc: *** set a breakpoint in malloc_error_break to debug
Upvotes: 4
Views: 2253
Reputation: 956
I had similar problem last week. I think updating to the latest version of fastlane and Xcode on my build machine fixed this.
Upvotes: 0
Reputation: 111
Well, remember to use the removeUIInterrutpionMonitor
method! The cause of the problem was that there were many UIInterruptionMonitor objects declared and there was a problem with threads. After adding removing UIInterruptionMonitor objects the problem disappeared. :)
Upvotes: 1