Skip to content
SDETRole
SDETRole

Glossary · UI automation

Behavior-Driven Development

Also called: BDD, behaviour-driven development, behavior driven development, behaviour driven development

Definition

A collaborative practice where business, development and testing agree on behavior through concrete examples, often written in Gherkin and automated.

Behavior-Driven Development (BDD) is a way of building shared understanding before code is written. Product, development and testing (often called the “three amigos”) discuss a feature through concrete examples of how it should behave. Those examples become the acceptance criteria, and many teams then automate them as executable specifications with tools such as Cucumber, SpecFlow’s successor Reqnroll, or Behave.

Example

A conversation about a discount rule turns into examples like this:

Feature: Loyalty discount

  Scenario: Gold members get 10% off orders over 100
    Given a customer with Gold membership
    When they check out a basket worth 120.00
    Then the order total is 108.00

  Scenario: The discount does not apply at exactly 100
    Given a customer with Gold membership
    When they check out a basket worth 100.00
    Then the order total is 100.00

The second scenario is the valuable one. Writing it forces the question “over 100, or 100 and over?” before anyone builds the wrong thing.

The three practices

  1. Discovery. Explore the feature with examples, find edge cases and open questions.
  2. Formulation. Write the agreed examples in a structured, business-readable form, usually Gherkin.
  3. Automation. Bind each step to code so the examples run as tests and act as living documentation.

Common mistakes

  • Treating BDD as a test tool. Writing Gherkin after the code, alone, with no conversation, gives you the cost of a translation layer without the benefit of shared understanding.
  • UI-level steps. “When I click the button with id submit” describes the interface, not the behavior. Steps should survive a redesign.
  • Automating every scenario through the browser. A business rule like the discount above is usually faster and more reliable to automate against an API or service layer.
  • Huge step libraries. Hundreds of slightly different step definitions are hard to maintain. Keep the vocabulary small and domain-focused.

BDD works well when business people actually read and contribute to the scenarios. When nobody outside engineering looks at them, plain test code with good names is often simpler.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →