BDD template
A practical Given/When/Then template
Given/When/Then is a compact way to describe a behavior in context. It is especially helpful when a story needs a shared, testable understanding across product, engineering and QA.
The template
Scenario: [brief behavior name] Given [the starting state or precondition] And [another relevant condition] When [the user or system takes an action] Then [the observable result] And [another expected result or side effect]
How to fill it in
| Part | What it should say | Example |
|---|---|---|
| Given | The context before the behavior starts. | A customer has an active subscription. |
| When | One action or event that triggers the behavior. | They cancel it from account settings. |
| Then | A result a person or system can observe. | Renewal is turned off and the end date is shown. |
| And | An additional result that belongs to the same scenario. | A confirmation email is sent. |
Examples to adapt
Required-field validation
Scenario: Prevent an incomplete profile from being saved Given a signed-in user is editing their profile When they leave the display name blank and select Save Then the display name field shows that it is required And no profile changes are saved
Access control
Scenario: Restrict an invoice to authorised users Given a user does not have billing permission When they open an invoice link Then they see an access-denied message And invoice details are not displayed
Common mistakes
- Putting several unrelated actions in one
When. - Using a vague
Thensuch as “the page works correctly.” - Writing the database or UI implementation instead of the needed behavior.
- Forgetting an important negative, validation or permission scenario.
Turn a requirement into BDD scenarios
Describe the feature in ordinary language and use CriteriaPilot to create a first draft you can refine with your team.
Create a BDD draft