Behaviour Driven Development

Term side of the Card.
Topic: Types of Development
Unit title: Behaviour Driven Development
Categories: Approach
Explanation side of the Card

Explanation: The development methodology that encourages collaboration between different roles in a project to define and document system behavior through clear, understandable scenarios, often using natural language.

Example

Wronggherkin
Scenario: Login
  Given I open "/login"
  When I type "a@b.co" into "#email"
  And I click "#submit"
  Then I see ".dashboard"
Rightgherkin
Scenario: Registered user signs in
  Given a registered user
  When they sign in with valid credentials
  Then they see their dashboard

The 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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy