Проблема стабильности iOS Swift UI Tests (XCUITests) - fastlane scan - PullRequest
4 голосов
/ 15 марта 2019

Во время выполнения iOS тестов через fastlane (сканирование) возникают случайные проблемы со стабильностью тестов.Ошибка, видимая в журналах:

Lost connection to the application (pid XXXX).
<unknown>:0

Кто-нибудь знает, что может быть причиной потери соединения с приложением?

Мои тесты реализованы в классах, и каждый из них наследует класс BaseTestприложение запускается следующим образом:

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()
    }

    ...
}

Также реализованы классы Page Object, каждый из которых наследует BaseScreen:

import XCTest

class BaseScreen {

    let app: XCUIApplication = XCUIApplication()
}

extension BaseScreen {
    func findAll(_ type: XCUIElement.ElementType) -> XCUIElementQuery {
        return app.descendants(matching: type)
    }
}

Тесты выполняются через fastlane следующим образом:

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

Я также использую UIInterruptionMonitor для оповещений, это также может иметь значение.

Отредактировано: В конце 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

Ответы [ 2 ]

0 голосов
/ 19 марта 2019

У меня была похожая проблема на прошлой неделе.Я думаю, что после обновления последней версии fastlane и версии Xcode на сборочной машине это можно исправить.Я устранял эти ошибки в течение месяцев

0 голосов
/ 19 марта 2019

Хорошо, не забудьте использовать метод removeUiInterrutpionMonitor!Причиной проблемы было то, что было объявлено много объектов UIInterruptionMonitor и возникла проблема с потоками.После добавления удаления объектов UIInterruptionMonitor проблема исчезла.:)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...