Quick / Nimble

A Matcher Framework for Swift and Objective-C
https://quick.github.io/Nimble/documentation/nimble/
Apache License 2.0
4.8k stars 596 forks source link

Nimble.PollingDefaults.timeout is set to 30 seconds, but toEventually gives up after ~5 #1087

Closed molenick closed 11 months ago

molenick commented 11 months ago

What did you do?

Installed via, pod and added an XCUITest:

import Nimble
import Quick
import XCTest

final class MyUITests: XCTestCase {
  class PollingConfiguration: QuickConfiguration {
    override class func configure(_: QCKConfiguration) {
      Nimble.PollingDefaults.timeout = .seconds(30)
    }
  }

  override func setUpWithError() throws {
    continueAfterFailure = false
  }

  func testUI() throws {
    let app = XCUIApplication()
    app.launch()

    expect(app.staticTexts["FirstScreen"].exists).toEventually(equal(true))
    app.buttons["Start"].tap()
    expect(app.staticTexts["SecondScreen"].exists).toEventually(equal(true))
    expect(app.staticTexts["ErrorScreen"].exists).toEventually(equal(true))
    expect(app.staticTexts["Timed out"].exists).toEventually(equal(true))
  }
}

StartScreen has a button that leads to an action that times out if it doesn't complete in 10 seconds. I'm trying to assert that the error screen is displayed after 10 seconds.

What did you expect to happen?

The test to wait 30 seconds before failing or pass.

What actually happened instead?

The test failed on this line after about 5 seconds: expect(app.staticTexts["ErrorScreen"].exists).toEventually(equal(true))

Environment

younata commented 11 months ago

Fascinating.

So, what's happening here is that QuickConfiguration.configure does not get called when you do not have any QuickSpec or AsyncSpecs.

I filed https://github.com/Quick/Quick/issues/1242 to better capture that, and get that fixed in a future version of Quick.

In the meantime, I'd suggest using the setupWithError class method on XCTestCase to configure Nimble's pollingDefaults.

I'm closing this because it's an issue with Quick, not Nimble.

molenick commented 11 months ago

Awesome, thank you so much! I'll try moving the polling config there. Have a good one! :)