Skip to content

Escaping callback closures execution order #51

Discussion options

You must be logged in to vote

The guarantee the library makes is that these will execute in the order defined in your .feature file. That means I could crash your tests by writing:

Given The user is on home screen
Then Map is visible

However, unless I maliciously manipulate your Gherkin (or you write such generic steps that accidental re-use causes issues) your code should be safe.

One way you could choose to rewrite this so that it fails, but doesn't crash is:

Given("^The user is on home screen$") { _, _ in
    XCTAssertTrue(app.staticTexts["Welcome!"].exists)
}
var mapScreen: MapScreen?
When("^Map button is tapped$") { _, _ in
    mapScreen = HomeScreen(app: app).tapMapButton()
}
Then("^Map is visible$") { _, _ in
    

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Tyler-Keith-Thompson
Comment options

@kublaios
Comment options

Answer selected by kublaios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants