Overview

3 What is an Example?

In this chapter, examples are presented as the concrete building blocks that make behavior-driven development specifications clear and unambiguous. A good example is made up of context, action, and outcome, with the outcome describing the expected post-condition, the action triggering the behavior, and the context setting the starting state. The chapter stresses that “concrete” does not mean cluttered with unnecessary detail; it means specific enough to clarify a rule without ambiguity.

The text also explains that examples should be narrowly focused and include only the data needed to illustrate one rule. Too much surrounding detail can obscure the behavior being discussed, so workshop participants should resist adding information that belongs to other rules. While examples are useful for revealing misunderstandings and side effects, the purpose of the requirements workshop is understanding, not exhaustive testing or perfect coverage.

Rules and examples are shown to be complementary rather than interchangeable. Rules provide the abstract statement of expected behavior, while examples provide the concrete illustrations that make those rules understandable and testable. The chapter argues that a story is specified by capturing the relevant rules and then illustrating each with a few focused examples, typically enough to clarify intent without drifting into exhaustive case enumeration or other documentation concerns.

Anatomy of an example
Anatomy of an example
Address change rule
Address change rule
State diagram of the order process showing the states in which an address change is possible
State diagram of the order process showing the states in which an address change is possible
Examples for the address change rule
Examples for the address change rule
Positive example of the order state rule
Positive example of the order state rule
Positive example of the valid address rule
Positive example of the valid address rule

Summary

  • All examples have three parts: context, action, and outcome.
  • The outcome is a description of the state of the system after the behavior we’re interested in has taken place.
  • The action is the event that triggers the behavior we’re interested in.
  • The context describes the state the system is in before the action takes place.
  • When creating an example it can be helpful to start with the desired outcome and work back towards the required context.
  • Examples need to be concrete to allow us to specify the requirements in detail.
  • The purpose of these examples is to reach a shared understanding of the work that needs to be done, not to provide exhaustive testing.
  • Rules and examples work together – both are equally important.
  • Each example should focus on illustrating a single rule.

FAQ

What makes an example “concrete” in BDD?An example is concrete when it describes a specific, unambiguous situation that clearly illustrates one possible behavior of the system. It usually includes a clear context, an action, and an outcome, with enough detail to avoid confusion.
What are the three parts of a concrete example?A concrete example is made up of context, action, and outcome. The context describes the starting state, the action is the trigger, and the outcome is the expected result after the behavior occurs.
Why shouldn’t we omit the context in an example?Even if the starting state seems obvious, omitting the context can make the example ambiguous. The chapter advises keeping the context explicit so the example remains clear and reliable.
Does every example need all available system data?No. An example should only include concrete data that is directly relevant to the rule being illustrated. Extra details that do not help explain the behavior should be left out.
How do examples help reveal mistakes or misunderstandings?Concrete examples force the team to notice contradictions, missing detail, and unwanted side effects. They can expose misunderstandings about requirements before implementation begins.
How many examples do we need for a story?There is no exact number. The chapter suggests that typical stories may have 3–5 rules, with each rule illustrated by about 2–4 examples, but the right number depends on the story and the team.
When should we stop adding more examples?Stop when additional examples no longer teach you anything new about the desired behavior or when they start to explore concerns the product owner is not interested in. At that point, the discussion is drifting away from requirements and into testing.
Are examples enough to specify a story on their own?No. Examples illustrate rules, but they do not replace them. To document expected behavior properly, you need both the abstract rule and the concrete examples that clarify it.
Why should each example focus on a single rule?Focused examples make workshops clearer and more efficient. If one example illustrates multiple rules, it may be helpful to split it into several examples so each one highlights a single rule more clearly.
What is the difference between a rule and an example?A rule is a general statement of expected behavior, while an example is a detailed, concrete situation that clarifies that rule. Rules provide the concise abstraction; examples provide the precise illustration.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Effective Behavior-Driven Development Effective Behavior-Driven Development ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Effective Behavior-Driven Development Effective Behavior-Driven Development ebook for free