Behaviour Driven Development
Example
Scenario: Login
Given I open "/login"
When I type "a@b.co" into "#email"
And I click "#submit"
Then I see ".dashboard"Scenario: Registered user signs in
Given a registered user
When they sign in with valid credentials
Then they see their dashboardThe scenario states behavior in domain language, so stakeholders can read it and UI changes do not break it.
Common mistakes
- Scenarios are full of clicks and selectors, so a redesign breaks all of them.
Key points
- Scenarios use Given, When, Then and describe behavior in domain words.
- Scenarios do not mention CSS selectors, URLs or other UI details.
- Each scenario checks one behavior.
Interview questions
What is Gherkin?
The plain-text format for BDD scenarios, built on the keywords Feature, Scenario, Given, When and Then.
Is BDD only for testers?
No. Its main value is that developers, testers and product people agree on behavior before code is written.