Behaviour driven development: from a conversation to an executable specification

TL;DR

Difficulty: Beginner

A one line request can be built in several reasonable ways, and tests only prove what the developer understood. Behaviour driven development (BDD) closes that gap before the code exists.

  • Hold a short conversation with three perspectives: business, development and testing (the three amigos).
  • Map the story into rules, concrete examples and open questions (example mapping, about 25 minutes).
  • Write each example as a declarative Given, When, Then scenario that proves one behaviour.
  • Run the scenarios as the outer loop and ordinary test driven development as the inner loop.
  • The scenarios stay behind as documentation the business can read and the computer checks.

One polite sentence from a business owner can describe four different features, and nobody notices until the wrong one ships. Behaviour driven development is how you catch that in ten minutes instead of ten weeks. Here it is from the beginning: where it comes from, the conversation at its heart, how examples become executable scenarios, and the first failing step in real Rails code.

One sentence, four different features

Hannah runs Fernhill Tea, an online tea shop in Bristol. Most of her income comes from subscriptions: a box of loose tea every month for £18, charged to the customer's card before it ships. One Monday she sends a short message to Priya, the developer who looks after the shop: "Customers keep asking if they can pause their subscription for a month. Can we add that?"

It sounds finished. It is one sentence, it is polite, and everyone knows what a pause is. Priya could start typing that afternoon. And this is exactly the moment where software projects quietly go wrong, because that sentence can be built in at least four different ways, and each of them is a reasonable reading.

This article answers one question: how do you make sure that what gets built is what the business actually meant? The answer has a name, behaviour driven development (BDD), and most of it happens before anyone writes a line of code. It builds on test driven development explained, the first chapter of this series. If you have never seen an automated test, read that one first.

Example: the four readings of "pause for a month"

Here is what Priya could build from Hannah's sentence, without asking a single question.

  1. Skip the next box. The customer presses pause, the next delivery does not happen, and the one after arrives as normal.
  2. Stop everything for 30 days. The pause starts today and ends 30 days later, wherever that lands in the delivery cycle. Pause the day after a box arrives, and the 30 days are over before the next one is due: nothing changes, and the customer wonders why the button did nothing.
  3. Freeze the billing, not the box. The box still ships, but the payment is moved back a month. Customers would love it. Hannah's bank balance would not.
  4. Pause until the customer comes back. "For a month" was only an example, and the subscription stays paused until someone presses resume.

All four are sensible. Only one is what Hannah meant, and nobody, including Hannah, has noticed yet that there is a choice to make. If Priya picks reading 2, the code can be beautiful, fully tested and still wrong. Tests prove that the code does what the developer understood. They cannot prove that the developer understood the right thing. That gap is what BDD closes.

Where BDD comes from

BDD was named by Dan North. In an article first published in Better Software magazine in March 2006, he described how teaching test driven development (TDD) kept running into the same confusion: where to start, what to test, what to call a test, and why it failed1.

His first step was small. He noticed that when tests were named as plain sentences, starting with "should", the list of names read like a description of what the system does. Business people could read it. Then he went further. He found that people's misunderstandings about TDD almost always came back to the word "test", so he started saying "behaviour" instead, and a whole category of coaching questions went away1.

The bigger step came in conversations with Chris Matts, a business analyst. When North described his behaviour based vocabulary, Matts said, in North's words, "But that's just like analysis." Together they applied the same thinking to requirements. They took the common story template ("As a [role], I want [feature], so that [benefit]") and added a template for the acceptance criteria of each story: Given some initial context, When an event occurs, Then ensure some outcomes1. Martin Fowler credits the Given, When, Then style to North and Matts as part of BDD, and points out that it is the same shape as the arrange, act, assert of an ordinary unit test2.

The idea also stands on older ground. In 2001 Ron Jeffries described a user story as three things: a card that names the requirement, a conversation in which the requirement is actually communicated, and a confirmation, the acceptance test that shows it is done. He wrote that the best supplements to the conversation are examples, and "the best examples are executable"3. BDD is, in one sentence, a disciplined way of getting from that conversation to that confirmation.

Example: naming tests as behaviour

Priya already has a unit test for the subscription model. Its old name is test_pause. That tells a reader nothing about what pausing should do. Renamed as behaviour, the same file in Minitest reads like this:

class SubscriptionTest < ActiveSupport::TestCase
  test "a pause before the cut off skips the next box" do
    # ...
  end

  test "a pause after the cut off skips the box after next" do
    # ...
  end
end

Read only the names, and you already know two rules of the feature. That was North's first discovery, and it still works: if you cannot name a test as a sentence about behaviour, you probably do not know yet what the behaviour is.

BDD is a conversation first, and tooling second

Many people meet BDD as a tool. They install Cucumber, write files full of Given, When, Then, and conclude that BDD is a way of writing tests in English. That is the smallest part of it.

The Cucumber project itself describes BDD as three practices that repeat for every small change4:

  • Discovery: talk about concrete examples of the new behaviour, to explore and agree on what is expected.
  • Formulation: write those examples down in a form that can be automated, and check that everyone still agrees.
  • Automation: implement the behaviour, starting with an automated test built from each example.

Notice the order. Discovery comes first, and it is a conversation between people. Skip it, and you get neatly formatted scenarios of the developer's assumptions. They pass, and they are still wrong in exactly the way the four readings above are wrong.

The Cucumber tooling (feature files, step definitions, tags, hooks) is covered in depth in my article on Cucumber and BDD. This chapter stays with the part that comes before the tooling.

Example: what the conversation produces that a document does not

Imagine Hannah had written a one page specification instead of a one line message. It might say: "Customers can pause their subscription for one month from their account page. Paused months are not charged." It reads well. It also still allows readings 1, 2 and 4, and it says nothing about a box that is already packed.

Now compare it with what a ten minute conversation produces (you will see the full version shortly): four rules, eight concrete examples with real dates, one open question, and one idea parked for later. The document was longer and decided less. The conversation was shorter and decided more, because every example forces an answer to "and then what exactly happens?"

The three amigos: business, development and testing

The conversation needs the right perspectives in the room. The Agile Alliance glossary calls them the three amigos, a term George Dinwiddie used in this sense in 20095. They are perspectives, not job titles:

  • Business: what problem are we trying to solve?
  • Development: how might we build a solution to that problem?
  • Testing: what about this, what could possibly happen?

The glossary is clear that the point is the smallest group that covers all three perspectives, not a meeting for the whole team, and not another ceremony on the calendar5.

In a small business the three amigos are rarely three specialists. The owner holds the business view. The developer holds the build view. The testing view is the one most often missing, and it belongs to whoever is professionally suspicious: often the person who answers customer emails, because they know every strange thing customers actually do.

Example: who sits at Fernhill Tea's table

For the pause feature, three people meet for a short call.

  • Hannah (business) knows why customers ask: holidays, and cupboards full of tea. She also knows that a skipped box is £18 of revenue that month.
  • Priya (development) knows how subscriptions work in the code: each one has a date for the next box, and boxes are charged and packed before they ship.
  • Tom (testing) packs the boxes and answers the emails. He asks the awkward questions. "What if someone pauses on the 27th, when their box is already paid for and sitting on my bench?" Nobody else would have thought of that before launch. Every customer would have found it in the first week.

Could Priya play the testing role herself? Partly, and she should try. But it is hard to find the gaps in your own understanding, which is exactly why the perspective works best when someone else brings it.

Example mapping: rules, examples and questions

Conversations wander. Matt Wynne, who leads the Cucumber project, published a simple method in 2015 to keep them short and productive, called example mapping6. You need four colours of index cards (or sticky notes, or four colours in a shared document):

  • a yellow card for the story under discussion, at the top;
  • a blue card for each rule (an acceptance criterion) you already know, in a row underneath;
  • green cards for the concrete examples that illustrate each rule, placed under that rule;
  • red cards for questions nobody in the room can answer.

Wynne adds several useful habits6. Give examples short names in the style of "the one where the customer forgot the receipt", rather than writing formal scenarios in the meeting. When nobody knows what the outcome should be, you do not have an example, you have a question: write it on a red card and move on instead of debating it. A well understood, well sized story should take about 25 minutes. And the table tells you something at a glance: lots of red cards means there is still a lot to learn, lots of blue cards means the story is big and should probably be sliced into smaller ones.

He is also explicit that the purpose is not to write tests during the session. The purpose is a shared understanding of what it will take for the story to be done6.

Tap or click to open full screen and move around

Example: mapping "pause for a month" in ten minutes

Here is the Fernhill Tea conversation, card by card. Priya shares a document with four coloured headings so everyone can see it.

Yellow, the story. As a subscriber, I want to pause my tea subscription for a month, so that I do not receive tea while I am away.

Priya starts with the obvious question: "When you say a month, do you mean the next box, or 30 days?" Hannah answers straight away: the next box. Readings 2, 3 and 4 are gone in one sentence. That becomes the first rule.

Blue, rule 1: a pause skips exactly one box, the next one.

  • Green: the one where Sam pauses on 20 February, so the 1 March box is skipped and the 1 April box arrives as normal.
  • Green: the one where Sam pauses in the middle of a long subscription, and only the next box is affected.

Hannah adds the money side without being asked.

Blue, rule 2: a skipped box is not charged.

  • Green: the one where Sam skips March, so no £18 payment is taken for March and the April payment is taken as normal.

Then Tom asks his question about the box that is already paid for and on his bench. Priya explains how the shop works today: every box is charged and packed on the 25th of the month before it ships. Hannah decides on the spot that a box already charged ships anyway.

Blue, rule 3: a pause after the cut off on the 25th applies to the box after next.

  • Green: the one where Sam pauses on 27 February, so the 1 March box still arrives and the 1 April box is skipped.
  • Green: the one where Sam pauses on 25 February itself. Hannah thinks for a moment: the charge runs early in the morning, so the 25th counts as after the cut off. Without this example, two developers would have written two different comparisons in the code.

Tom has a second question: "Can someone pause every month and never pay, but keep their subscription discount forever?" Hannah does not want that.

Blue, rule 4: a subscription can only be paused for one month at a time.

  • Green: the one where Sam has paused March and tries to pause April as well, and is told he can pause one month at a time.
  • Green: the one where Sam paused March, received the April box, and pauses May. That is allowed, because the pauses are not in a row.

Then a question nobody can answer. Some customers joined with a code for 20% off their first three boxes. Does a skipped box count as one of the three?

Red: does a skipped box use up one of the three discounted boxes? Hannah wants to think about it and will decide by Friday. The group writes it down and moves on, which is exactly the habit Wynne describes.

Finally Hannah says: "Some people want to pause for the whole summer." That is a bigger change, with its own questions.

Yellow, parked: pause for longer than one month. A new story for another day.

The whole thing took about ten minutes. Four blue cards, seven green ones, one red one, one parked story. There is one red card, it does not block the three rules everyone is sure of, and the group agrees the story is ready to build, with the discount question to be answered before the discount part goes live.

From story to acceptance criteria to Given, When, Then

Now the formulation step. Each blue card is an acceptance criterion: a condition that must be true for the story to count as done. North and Matts put it simply: if the system fulfils all the acceptance criteria, it is behaving correctly, and if it does not, it is not1. Each green card becomes one scenario that proves one criterion with one concrete case.

A scenario has three parts. The Gherkin reference, the language Cucumber reads, defines them like this7:

  • Given describes the starting situation, typically something that happened in the past. It puts the system into a known state. It should not describe a user clicking things.
  • When describes the event: a person doing something, or another system triggering something.
  • Then describes the expected outcome, and it should be something you can observe from outside (a page, a message, an email, a report), not a record hidden deep inside a database.

Gherkin also has a keyword called Rule, available since version 6, which exists to group the scenarios that illustrate one business rule7. That is an almost exact match for a blue card with its green cards underneath, so the map from the conversation translates straight into the file.

Example: turning one green card into a scenario

Take the first green card under rule 1: "the one where Sam pauses on 20 February, so the 1 March box is skipped and the 1 April box arrives as normal". Priya turns it into a scenario in four moves.

  1. What is true before anything happens? Sam has a monthly subscription, and his next box is due on 1 March 2027. That is the Given.
  2. What does Sam do? He pauses the subscription on 20 February 2027. That is the When. The date matters, because rule 3 makes the date decide the outcome.
  3. What can Sam see afterwards? His account shows that the 1 March box is skipped and not charged. That is the first Then.
  4. What else must be true? The account shows the next box on 1 April 2027. That is the And, a second outcome of the same single event.

Written out:

Scenario: A pause before the cut off skips the next box
  Given Sam has a monthly subscription with the next box due on 1 March 2027
  When Sam pauses the subscription on 20 February 2027
  Then the box due on 1 March 2027 is shown as skipped and not charged
  And the next box is shown as due on 1 April 2027

Hannah can read every line of that and say "yes, that is what I meant", or "no, that is not". That is the whole point. The scenario is a requirement she can check and a test the computer can run, in one artefact.

Declarative scenarios, not imperative scripts

There are two ways to write the same scenario. An imperative scenario lists the clicks: visit this page, fill in this field, press this button. A declarative scenario describes the behaviour and leaves the clicks to the code underneath.

The Cucumber documentation recommends the declarative style and gives a test for it: ask yourself, "Will this wording need to change if the implementation does?" If the answer is yes, rewrite it without the implementation details8. The Gherkin reference puts it more vividly for When steps: imagine it is 1922, when there were no computers, and describe the action in a way that still makes sense7. Imperative scenarios are not forbidden, they say, but they are tied to the current screen and need more work every time the screen changes8.

Example: the same pause, written two ways

Here is the imperative version Priya might have written if she had gone straight to the keyboard:

Scenario: Pause subscription
  Given I am logged in as "sam@fernhilltea.example"
  And I visit "/account/subscriptions/42"
  When I click "Manage subscription"
  And I click "Pause next box"
  And I click "Confirm"
  Then I should see "Your 1 March box is skipped"

Count what is wrong with it. It names a database id (42) that means nothing to Hannah. It will break the day the designer renames "Manage subscription" to "Settings". It hides the date, which is the one thing that decides the outcome under rule 3. And the title "Pause subscription" says nothing about which rule it proves.

The declarative version from the previous section survives a redesign, a move from a button to a link, even a future voice assistant, because none of those change the behaviour. The clicks still exist, of course. They move into the step definition, the Ruby code underneath, which is the one place that should change when the screen changes.

One behaviour per scenario

A scenario that proves three things fails for three reasons, and when it fails at 7pm before a release, nobody knows which of the three broke. The Gherkin reference recommends three to five steps per example, because more steps make an example lose its power as a specification7. A useful habit on top: exactly one When in each scenario. If you need a second When, you are describing a second behaviour, so write a second scenario.

Example: splitting a scenario that tried to do everything

Here is a scenario that grew during a busy afternoon:

Scenario: Pausing works
  Given Sam has a monthly subscription with the next box due on 1 March 2027
  When Sam pauses the subscription on 20 February 2027
  Then the box due on 1 March 2027 is shown as skipped and not charged
  When Sam tries to pause the subscription again on 21 February 2027
  Then Sam is told that a subscription can be paused for one month at a time
  When Sam pauses the subscription on 2 March 2027
  Then the box due on 1 April 2027 is shown as skipped and not charged

It has three Whens, so it proves three behaviours. It also hides a contradiction: rule 4 forbids pausing two months in a row, so the last When should be refused, and the final Then is wrong. It would take a careful reader several minutes to notice. Split by behaviour, each part maps to one blue card, and the mistake becomes impossible to miss: the third piece clearly belongs under rule 4, where the expected outcome is a refusal, not a skipped box.

Three scenarios for the pause feature

Here is the feature file Priya writes after the conversation, for the three rules everyone was sure of. Rule 2 (not charged) is covered inside the first scenario's outcome, because it is the same single event seen from the money side. The red card about the discount stays out until Hannah decides.

Feature: Pause a subscription for one month
  As a subscriber
  I want to pause my tea subscription for a month
  So that I do not receive tea while I am away

  Rule: A pause skips exactly the next box, and a skipped box is not charged

    Scenario: A pause before the cut off skips the next box
      Given Sam has a monthly subscription with the next box due on 1 March 2027
      When Sam pauses the subscription on 20 February 2027
      Then the box due on 1 March 2027 is shown as skipped and not charged
      And the next box is shown as due on 1 April 2027

  Rule: Boxes are charged and packed on the 25th, so a later pause moves to the box after

    Scenario: A pause after the cut off skips the box after next
      Given Sam has a monthly subscription with the next box due on 1 March 2027
      When Sam pauses the subscription on 27 February 2027
      Then the box due on 1 March 2027 is shown as due
      And the box due on 1 April 2027 is shown as skipped and not charged

  Rule: A subscription can be paused for one month at a time

    Scenario: A second pause in a row is refused
      Given Sam has paused the box due on 1 March 2027
      When Sam pauses the subscription on 2 March 2027
      Then Sam is told that a subscription can be paused for one month at a time
      And the box due on 1 April 2027 is shown as due

Read it from top to bottom. The Feature block carries the story from the yellow card. Each Rule is a blue card, word for word. Each Scenario is one green card, with real dates. Every scenario has one When and four steps. There is not a URL, a button label or a database id anywhere.

The remaining green cards (pausing on the 25th itself, a pause in May after a box in April) become further scenarios under the same rules. Some of them may end up as unit tests instead of scenarios, which is the subject of the next section, and of the chapter on unit, integration and end to end tests.

Two loops: BDD on the outside, TDD on the inside

How do the scenarios and ordinary unit tests fit together? Steve Freeman and Nat Pryce gave the clearest answer in Growing Object Oriented Software, Guided by Tests (2009). Their figure of TDD with acceptance test and unit test cycles shows two loops, one inside the other9.

  • The outer loop starts with a failing acceptance test: here, a scenario. It describes one behaviour of the whole system, as the customer sees it. It stays red while you work, sometimes for hours.
  • The inner loop is ordinary red, green, refactor, the loop from chapter 1. You write a small failing unit test for one piece the scenario needs, make it pass, tidy up, and repeat. Each turn takes minutes.
  • When enough inner turns are done, the scenario turns green. Then you pick the next scenario.

The outer loop keeps you building the right thing. The inner loop keeps you building the thing right. Neither replaces the other. A scenario alone tells you that something is broken but not where. Unit tests alone can all be green while the feature as a whole still does not do what Hannah meant.

This is how I work: test first, with BDD scenarios as the outer loop (in Cucumber, or as tests with Capybara and Playwright) and Minitest or RSpec for the inner loop.

Tap or click to open full screen and move around

Example: the first failing step

Priya starts the outer loop with the first scenario. When Cucumber meets a step that no code understands yet, it marks the step as undefined, skips the rest of the scenario and suggests a snippet of code to start from10. Priya writes the step definitions, the Ruby code that turns each sentence into actions on the real application. Cucumber lets a step contain a placeholder in curly brackets, called a parameter type, and lets you define your own11. Priya defines {date} so that "1 March 2027" arrives in the code as a real date:

# features/support/parameter_types.rb
ParameterType(
  name: "date",
  regexp: /\d{1,2} [A-Z][a-z]+ \d{4}/,
  transformer: ->(text) { Date.parse(text) }
)

Line by line: the parameter is called date. The regular expression matches one or two digits, a capitalised month name and a four digit year. The transformer takes the matched text and turns it into a Ruby Date.

# features/step_definitions/subscription_steps.rb
World(ActiveSupport::Testing::TimeHelpers)

Given("Sam has a monthly subscription with the next box due on {date}") do |date|
  @sam = Customer.create!(name: "Sam", email: "sam@fernhilltea.example")
  @subscription = @sam.subscriptions.create!(plan: "monthly", next_box_on: date)
end

When("Sam pauses the subscription on {date}") do |date|
  travel_to(date) do
    sign_in_as(@sam)
    visit account_subscription_path(@subscription)
    click_button "Pause next box"
  end
end

Then("the box due on {date} is shown as skipped and not charged") do |date|
  expect(page).to have_text("#{date.strftime('%-d %B %Y')}: skipped, not charged")
end

What each part does. World(...) makes Rails' time helpers available inside the steps, so travel_to can pretend today is a given date, and travel_to with a block puts the clock back afterwards12. The Given creates Sam and his subscription directly, because Given describes a state, not a set of clicks. The When signs Sam in (sign_in_as is a small helper Priya keeps in features/support), opens his subscription page and presses the button. This is where the clicks of the imperative version went: into one place, under the declarative sentence. The Then checks what Sam can actually see on the page.

Priya runs it:

bundle exec cucumber features/subscriptions/pause.feature

The Given passes, because the shop already has customers and subscriptions. The When fails. Capybara, the library that drives the browser, reports that it cannot find a button called "Pause next box". That is the first failing step, and it fails for the right reason: the feature does not exist yet. If it had failed because Sam could not be created, the scenario would be broken, not the feature, and Priya would fix that first. This is the decision at the top of the diagram.

Now she drops into the inner loop. The first piece the scenario needs is the rule itself: which box does a pause skip? That is plain logic, no browser required, so it gets a unit test in Minitest:

# test/models/subscription_test.rb
require "test_helper"

class SubscriptionTest < ActiveSupport::TestCase
  test "a pause before the cut off skips the next box" do
    subscription = subscriptions(:sam_monthly) # next box due on 1 March 2027

    subscription.pause!(on: Date.new(2027, 2, 20))

    assert_equal Date.new(2027, 3, 1), subscription.skipped_box_on
    assert_equal Date.new(2027, 4, 1), subscription.next_box_on
  end
end

subscriptions(:sam_monthly) loads a prepared subscription from the test fixtures. The test pauses it on 20 February and asserts two outcomes: the skipped box is the 1 March one, and the next box is now 1 April. Run with bin/rails test test/models/subscription_test.rb, it fails with an error that pause! does not exist. Red, for the right reason.

The simplest code that passes (after a migration that adds a skipped_box_on date column) is this:

class Subscription < ApplicationRecord
  def pause!(on:)
    update!(skipped_box_on: next_box_on, next_box_on: next_box_on.next_month)
  end
end

It ignores the on: date completely, and that is deliberate. No test asks for the cut off yet. The next unit test, "a pause after the cut off skips the box after next", will fail against this code and force the cut off rule in, the way chapter 1 describes triangulation. After that, a controller action and the button. Then Priya runs the scenario again, and the When step passes. The outer loop moves to the Then. One scenario, a handful of inner turns, and the first rule from a ten minute conversation is now proven by the computer on every run.

What a business owner should ask for

You do not need to read Ruby to get the benefit of BDD. You need to be part of the conversation and able to read the result. The Cucumber project describes the scenarios as documentation that is automatically checked against the system's behaviour4. Unlike a specification in a shared drive, it cannot quietly go out of date: if the software stops doing what a scenario says, the scenario fails.

Five things are worth asking anyone who builds software for you:

  1. Invite me to the conversation before you build. Ten to 25 minutes per story, with examples, not a long requirements meeting.
  2. Show me the rules and examples, in my words. If I cannot read a scenario aloud and agree with it, it is not finished.
  3. Give me the open questions as a list. The red cards are decisions only I can make. Better on Monday than discovered by a customer.
  4. Show me the scenarios passing before a release. A green run of the scenarios is the confirmation from Jeffries' third C3.
  5. Mark the scenarios that must never break. Some behaviours earn the business money or keep it legal. They deserve more protection than the rest, which is the subject of the chapter on the critical path in software.

Example: Hannah's five questions, answered for the pause feature

  1. Hannah was in the conversation, with Tom, for about ten minutes.
  2. She read the feature file above, line by line, and agreed. She asked for one change: "shown as skipped and not charged" instead of Priya's first draft "status is skipped", because customers will see that wording.
  3. She got one red card. On Friday she decided that a skipped box does not use up one of the three discounted boxes. Priya added a fourth rule and a scenario for it.
  4. Before release, Priya sent her the run: every scenario for the feature passing, by name.
  5. Hannah marked the second scenario as one that must never break. A box charged and then skipped means a refund, an apology and an unhappy customer, and Tom's bench full of boxes nobody wants.

When BDD is more than you need

BDD is not free. The conversation costs everyone's time, and scenarios are code that must be maintained. Wynne himself notes that some rules are so obvious that nobody needs examples for them6, and the same judgement applies to whole changes. A change with no business rule in it (a new photo, a corrected price, a typo) does not need three amigos. A change where a reasonable person could read the request in two different ways does. That is the test: if you can imagine two developers building it differently, have the conversation.

The tooling is optional too. The conversation and the examples are BDD. Whether the examples then live in Cucumber feature files, in RSpec or Minitest system tests with Capybara, or in Playwright tests is a practical choice. Feature files are worth their upkeep when non developers read them. When nobody outside the code ever will, well named tests in the same Given, When, Then shape can carry the examples just as faithfully.

Example: two requests in the same week

In the same week as the pause feature, Hannah sends a second message: "Please change the photo on the Earl Grey page, the new one is attached." There is one reading. Priya swaps the photo, checks the page and moves on. No conversation, no scenario, and nothing lost.

Then a third message: "Can we give subscribers free shipping?" Priya stops. Free shipping on the subscription box, or on every order a subscriber places? On a paused month? For subscribers abroad? Four readings again. That one gets a yellow card and ten minutes with Hannah and Tom.

Conclusion: the conversation is the specification

BDD began as a better way to explain TDD and grew into a way of agreeing what to build. Its core is not a tool. It is a short, structured conversation between the business, development and testing perspectives, held before the code, that turns a vague sentence into rules, concrete examples and honest questions. Those examples are then written as scenarios in Given, When, Then, declarative and one behaviour each, which the business can read and the computer can run. They become the outer loop around ordinary test driven development, and they stay behind as documentation that cannot drift.

They matter even more when an AI assistant writes part of the code. A machine can read "add a pause feature" four ways as easily as a person can. Agreed scenarios give it a precise target, and give you a check that does not depend on what the assistant claims. Setting that up for a whole project is the subject of test driven development with AI.

Hannah's one line message could have produced four different features. Ten minutes with three people produced the one she meant, plus a question nobody had seen and a story for later. That costs far less than building the wrong feature and building it again, and it is where building the right thing starts.

If you want the features you ask for built the way you meant them, book the free workshop: we map one of your real stories into rules and examples together, and the first two weeks of work are on me.

Sources

  1. 1.

    Dan North, Introducing BDD, first published in Better Software magazine, March 2006, dannorth.net, https://dannorth.net/blog/introducing-bdd/

  2. 2.

    Martin Fowler, GivenWhenThen, martinfowler.com, 21 August 2013, https://martinfowler.com/bliki/GivenWhenThen.html

  3. 3.

    Ron Jeffries, Essential XP: Card, Conversation, Confirmation, ronjeffries.com, 30 August 2001, https://ronjeffries.com/xprog/articles/expcardconversationconfirmation/

  4. 4.

    Cucumber, Behaviour Driven Development, Cucumber documentation, https://cucumber.io/docs/bdd/

  5. 5.

    Agile Alliance, Three Amigos, Agile Glossary, https://www.agilealliance.org/glossary/three-amigos/

  6. 6.

    Matt Wynne, Introducing Example Mapping, Cucumber blog, 8 December 2015, https://cucumber.io/blog/bdd/example-mapping-introduction/

  7. 7.

    Cucumber, Gherkin reference, Cucumber documentation, https://cucumber.io/docs/gherkin/reference/

  8. 8.

    Cucumber, Writing better Gherkin, Cucumber documentation, https://cucumber.io/docs/bdd/better-gherkin/

  9. 9.

    Steve Freeman and Nat Pryce, Growing Object Oriented Software, Guided by Tests, Addison Wesley, 2009, figure "TDD with acceptance and unit test cycles", https://growing-object-oriented-software.com/figures.html

  10. 10.

    Cucumber, 10 minute tutorial, https://cucumber.io/docs/guides/10-minute-tutorial/ and API reference, step results, https://cucumber.io/docs/cucumber/api/, Cucumber documentation

  11. 11.

    Cucumber, Cucumber Expressions, Cucumber documentation, https://cucumber.io/docs/cucumber/cucumber-expressions/

  12. 12.

    Ruby on Rails API, ActiveSupport::Testing::TimeHelpers, https://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html