Overview

Appendix B. Pattern catalog

The pattern catalog presents a practical toolkit for writing and supporting behavior-driven scenarios, organized around common needs in scenario design, automation structure, data handling, setup, and diagnostics. At its core, it emphasizes keeping scenarios readable and business-oriented while still giving teams ways to share context safely, introduce and reference entities clearly, select items from collections, and manage domain terminology consistently. It also highlights approaches for building reusable test data and validation helpers, such as defaults, factories, builders, table accessors, and specialized assertion support, all aimed at reducing duplication and keeping step definitions focused on intent rather than plumbing.

A second major theme is structuring the automation layer so that tests remain maintainable as systems and test suites grow. The catalog describes patterns for hiding technical complexity behind drivers, infrastructure adapters, and test actions, while also supporting more advanced execution needs like alternate interfaces, expected failures, and stubs for hard-to-control dependencies. In the same spirit, it offers ways to simplify scenario setup with shared resources, shortcuts, implicit prerequisites, and approval-style checks, while preserving clarity and keeping the behavior under test visible in the scenario narrative.

The remaining patterns focus on reliability, flexibility, and diagnosability across the test lifecycle. They cover repeatable environment management through resets, seeded data, and selective cleanup; configurable execution through providers, parameterization, and scenario-specific behavior; and staging techniques for shared infrastructure, resource pools, and file-system-dependent tests. The catalog also stresses fast failure analysis through descriptive assertions, supplementary attachments, test logs, embedded application logs, and corroboration checks. Overall, the chapter serves as a catalogue of proven design choices for making BDD suites expressive, resilient, and efficient without sacrificing communication with the business.

FAQ

What is the purpose of the Local Scenario Context pattern?It lets scenario steps share information during execution while keeping that information isolated so it cannot affect other scenario runs.
When should I use the Shareable Scenario Context pattern?Use it when steps need to share data across glue code classes or files, and the scenario automation tool can manage the lifetime of shared data structures.
How does the Introduce and Refer pattern improve scenario readability?It uses natural language phrases to clearly distinguish when a new entity is being introduced versus when an existing entity is being referenced later in the scenario.
What problem does the Entity Selector pattern solve?It provides business-readable selection logic so scenarios can pick specific entities from a collection without exposing technical details.
Why is the Domain Default pattern useful?It centralizes default test values so teams can promote consistency and reduce duplicated automation code.
What is the difference between Default Instance and Object Mother?Default Instance centralizes the creation of default test objects, while Object Mother centralizes the creation of customized test objects tailored to a scenario.
What does the Data Table Accessor pattern help with?It simplifies working with Gherkin data tables by providing a shared mechanism that can handle optional columns cleanly.
Why is the Data Table Assertion pattern recommended?It allows a single assertion to compare expected and actual table data and produce a diagnostic that shows all differences at once.
What is the role of the Test Driver pattern?It hides unnecessary details of a component’s API from step definitions, making test code easier to maintain and work with.
How does the Resource Pooling pattern support parallel testing?It provides a limited pool of costly external resources so scenarios can run in parallel, as long as the pool implementation is thread safe.

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