0

What BDD really asks of a team, and how it pairs with TDD

On one project I worked on, a product owner, a backend developer, and a QA engineer spent an hour agreeing on how order cancellation should work. Everyone left the room happy. When the feature reached staging, all three of them filed bugs against it, and each bug described a different "correct" behavior. Nobody was careless. They had each built a different picture in their head from the same conversation.

Behavior driven development exists to catch that kind of mismatch early.

So what is BDD?

In short, BDD is a habit of agreeing on how a system should behave before building it, using concrete examples written in language the whole team can follow. Those examples are then turned into automated tests.

The idea came from Dan North in the early 2000s. He was teaching test driven development and kept noticing that people got stuck on the word "test." They wanted to know what to test, how much, and where to start. Shifting the conversation to "behavior" made it easier: describe what the system should do in a specific situation, and test exactly that.

When I need a precise behavior driven development definition, I go to the Keploy glossary entry. It has the full Gherkin keyword reference, example feature files, and a short rundown of tools like Cucumber, Behave, and pytest-bdd.

How it works day to day

Day to day, BDD cycles through three practices.

Discovery. Business, development, and testing sit together (often called a "Three Amigos" session) and walk through real examples. What happens when a user applies an expired coupon? What if the cart is empty? This is where most of the value is, because misunderstandings surface while they are still cheap.

Formulation. The examples get written down in a structured format, usually Gherkin:

Feature: Discount coupons at checkout

  Scenario: Expired coupon is rejected
    Given a cart with items worth 50 dollars
    And a coupon "SPRING10" that expired yesterday
    When the customer applies the coupon
    Then the total stays at 50 dollars
    And the customer sees "This coupon has expired"

Anyone on the team can read that. That is the point.

Automation. Developers write step definitions that connect each line to real code, then run the scenarios in CI. Now the examples double as living documentation: if the behavior changes, the scenario fails and tells you.

BDD and BDD testing are not the same thing

Mixing these two up is very common. BDD covers the entire collaborative process, including the conversations. BDD testing is just the automated piece where scenarios run. Plenty of teams install Cucumber, write Gherkin alone at their desk, and call it BDD. They get the syntax overhead without the shared understanding, and then wonder why it feels like extra work.

BDD vs TDD

You will often see these two described as competing approaches. In reality they solve problems at different levels of the system.

TDD works at the code level. You write a small failing test, write just enough code to pass it, then refactor. Red, green, refactor. The tests are written by developers, in code, and they check that individual units do what the developer intended.

BDD works at the behavior level. Scenarios describe what the system should do from a user's point of view, in plain language, and they are shaped by people who may never read the code.

A quick way to tell them apart:

  • TDD asks "does this function work correctly?"
  • BDD asks "are we building the right thing?"

TDD shines for complex backend logic, services with lots of edge cases, and anywhere you need tight unit coverage. BDD shines for user facing workflows and projects where requirements come out of conversations with the business.

Many strong teams combine them. The BDD scenario describes the outcome, and TDD builds the code underneath it step by step. For a deeper look, this comparison of behaviour driven development vs test driven development includes a side by side table and worked examples of each.

When BDD is not worth it

BDD has a real cost. Discovery sessions take time, and feature files need maintenance like any other code. It usually does not pay off for:

  • solo projects where there is nobody to align with,
  • internal libraries with no business stakeholders,
  • short lived prototypes you plan to throw away.

It also does not give you complete coverage on its own. Scenarios capture the behaviors you thought to discuss, not every edge case your users will find.

A few habits that help

  • Write steps declaratively. "When the customer applies the coupon" beats "When I click the button with id apply-btn."
  • Keep one behavior per scenario.
  • Use the words your business actually uses, not internal code names.
  • Include failure cases, not just happy paths.
  • Tag scenarios so you can run fast subsets in CI and the full set nightly.

If that product owner, developer, and QA engineer had written down three cancellation examples together, the disagreement would have shown up in the meeting, not in staging. That is the whole idea behind BDD.


All Rights Reserved

Viblo
Let's register a Viblo Account to get more interesting posts.