Feb. 11, 2021, 10:51 p.m.

Given-When-Then: Describing the system state

Known Unknowns

User scenarios describe the changes in the system’s state:

  • A “given” statement is a precondition. It describes the past state.
  • A “when” statement is the current event. It is what is happening now.
  • A “then” statement describes the future; what we would like the state to look like after the event.

To that end, in 4 Rules for Writing Good Gherkin, Andy Knight recommends the following tenses when writing scenarios:

  • Given steps should use past or present-perfect tense, because they represent an initial state that must already be established.
  • When steps should use present tense, because they represent actions actively performed as part of the behavior.
  • Then steps should use present or future tense, because they represent what should happen after the behavior actions.

Use the correct tense, and your BDD scenarios will be clearer.

You just read issue #52 of Known Unknowns. You can also browse the full archives of this newsletter.

This email brought to you by Buttondown, the easiest way to start and grow your newsletter.