Why do XCTest UI tests fail sometimes with the error "Failed to receive event delivery confirmation within [n seconds] of the original dispatch"
Asked Answered
J

0

6

I have a fairly normal XCTest UI test for a Mac application which clicks some menu items in the application menu to open a window.

In some places - like my own Mac - the tests work fine. But in other places - like on Travis CI - they fail, with this error:

UI Testing Failure - Failed to receive event delivery confirmation within 2.5s of the original dispatch.
...
menuBarsQuery.menuBarItems["Top level menu item"].click()
menuBarsQuery.menuItems["Menu item in sub menu"].click()

System:

  • Mac OS 10.11.5
  • Xcode 7.2.1
  • Mac OS SDK version: 10.11.2
  • Swift 2.1.1

Slightly sanitised version of the test case:

import XCTest

class FooUITests: XCTestCase {

    override func setUp() {
        super.setUp()
        continueAfterFailure = false
        XCUIApplication().launch()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testCanDoSomething() {
        let app = XCUIApplication()

        let menuBarsQuery = app.menuBars
        menuBarsQuery.menuBarItems["Top level menu item"].click()
        menuBarsQuery.menuItems["Menu item in sub menu"].click()

        let window = app.windows["Foo"]

        // Rest of test, assertions, actions in window etc.
    }

}

It's not reproducible locally, so I'll ask the audience... why would this error happen?

Judon answered 3/8, 2016 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.