I read in a Cucumber book that the format for a Cucumber feature scenario should be that of a Gherkin scenario, i.e.: Given-When-Then
To simplify things, let's omit the And elements that can appear in a scenario.
I have often seen in my current project several scenarios defined like this: Scenario X Given-Then-When-Then
Is this format correct? Cucumber accepts it, but is it good practice?
The Given
, When
, and Then
keywords are actually aliases of the same method, so they can be used interchangeably. Gherkin
is just providing more human-readable hooks to write scenarios.
As far as a Given/Then/When/Then
sequence in a scenario, that'll work, but it does seem a bit unusual. I realize that you're trying to keep your question simple, but this sounds like a possible case for using And
or But
. For example: Given/And/When/Then
or Given/But/When/Then
. And FWIW, you can use *
to start a step if you want to avoid the semantic gymnastics of Given/When/Then/And/But