Fixed SwiftUI UI tests not finding the right state to tap if not already displayed on screen.

This commit is contained in:
Stefan Ceriu
2021-12-16 16:29:07 +02:00
committed by Stefan Ceriu
parent 3e6ecb27bb
commit 5aa59e87fe
9 changed files with 54 additions and 43 deletions
@@ -45,9 +45,10 @@ class MockScreenTest: XCTestCase {
guard let screenType = screenType else {
return testSuite
}
// Create a test case for each screen state
screenType.screenStates.enumerated().forEach { index, screenState in
let key = screenType.screenStateKeys[index]
let key = screenType.screenNames[index]
addTestFor(screenState: screenState, screenStateKey: key, toTestSuite: testSuite)
}
return testSuite
@@ -64,12 +65,8 @@ class MockScreenTest: XCTestCase {
// For every test case launch the app and go to the relevant screen
continueAfterFailure = false
app.launch()
goToScreen()
}
private func goToScreen() {
guard let screenKey = screenStateKey else { fatalError("no screen") }
let link = app.buttons[screenKey]
link.tap()
app.goToScreenWithIdentifier(screenKey)
}
}