SnuwFox
SnuwFox

Reputation: 1

XCUI continue test loop even when fail

I'm running a test that launch a list of bundleID one by one and check if a specific button exist in the app. My current issue is when one app does not have the button -> test fail, but then the test stops checking the next bundleID.

How do I make the test continue checking the next bundleID?

Here is what I have now

func testLaunchApp() {
    let bundles = ["com.App1", "com.App2", "com.App3", "com.App4"]
    for bundle in bundles {
        XCContext.runActivity(named: "Test launching \(bundle)") { activity in
            setUp()
            testToBeLoop(bundle: bundle)
            tearDown()
        }
    }
}


func testToBeLoop(bundle: String){
    let app = XCUIApplication(bundleIdentifier: bundle)
    app.launch()

    let theButton = app.button["myButton"]
    let isVisible = theButton.waitForExistence(timeout: 1)
    XCTAssert(isVisible, "Button is not visible)
}

Currently, if "com.App3" failed the Assert, the test will stopped without checking "com.App4" next.

Upvotes: 0

Views: 20

Answers (1)

Mike Collins
Mike Collins

Reputation: 4559

You're going to want your test class to inherit from XCTestCase and then you'll set the continueAfterFailure property to true. More information available in the Apple docs.

Upvotes: 0

Related Questions