Disabling waiting for idle state in UI testing of iOS apps

后端 未结 5 1112
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 12:37

Basically the problem is the same as this one: XCTestCase: Wait for app to idle

I am using perpetually repeating \"background animations\" in my views. The !@#$#$&@

5条回答
  •  有刺的猬
    2021-02-04 12:59

    Unfortunately using Apple's UI Testing you can't turn 'wait for app to idle' or poll other network activity, however you can use environment variables to disable animations in your app to make the tests more stable. In your setup method before your test set an environment variable like this.

    override func setUp() {
        super.setUp()
        continueAfterFailure = false
        let app = XCUIApplication()
        app.launchEnvironment = ["UITEST_DISABLE_ANIMATIONS" : "YES"]
        app.launch()
    }
    

    Now in your source code:

    if (ProcessInfo.processInfo.environment["UITEST_DISABLE_ANIMATIONS"] == "YES") {
        UIView.setAnimationsEnabled(false)
    }
    

    You can place that check in a specific view if you only want it to disable animations for that specific view or in a delegate file to disable animations throughout the app.

提交回复
热议问题