Overview

12 Getting ready for scenario automation

This chapter explains how teams can approach scenario automation without rushing into a brittle or costly solution. It opens by showing that automation projects often fail to deliver the promised speed and reliability, so the safer approach is to treat automation as a set of experiments, especially when the team lacks experience or the product is not yet easy to test. A proof-of-concept lets the team learn, try out options, and build confidence before automating everything, reducing the risk of accumulating quality debt that slows delivery later.

The chapter then introduces design patterns as a way to capture recurring automation solutions and reuse them consistently. It emphasizes that patterns are general solutions for specific contexts, should be documented clearly with their intent, applicability, and tradeoffs, and can be organized into pattern languages that help teams navigate related choices. The chapter also surveys scenario automation tool capabilities, including step definitions, expressions and parameters, custom parameter types, hooks, and glue code organization, while highlighting differences between tools such as Reqnroll and Cucumber-JVM.

Finally, the chapter presents the SUITABLE principles for effective scenario automation: use shortcuts to set up context efficiently, provide understandable diagnostics, keep scenarios isolated, treat test code as first-class code, prefer atomic assertions, use business terminology, design for loose coupling, and maintain fast feedback. It concludes by framing automation strategy as a set of architectural choices: which interface layer to test through, whether to use real infrastructure or stubs, and how to balance speed, robustness, and confidence. The central message is that good scenario automation is deliberate, maintainable, and guided by experimentation rather than by rigid rules or a browser-only mindset.

Map of idiomatic scenario pattern languages
Map of idiomatic scenario pattern languages
Map of flexible automation pattern languages
Map of flexible automation pattern languages
Developer workflow for automating a scenario
Developer workflow for automating a scenario
Conceptual approach for matching step text to step definition
Conceptual approach for matching step text to step definition
A simple folder hierarchy for glue code
A simple folder hierarchy for glue code
Various possible automation interface layers
Various possible automation interface layers

Summary

  • Take a low risk, proof-of-concept approach to adopting BDD automation.
  • Software design patterns are a concise way to document successful solutions for future reference.
  • A scenario automation tool is a tool that turns scenarios into automated tests, such as Cucumber and Reqnroll.
  • Glue code is what we call the automation code that is invoked by the scenario automation tool, because it connects the specification to the system being developed.
  • Step definitions are the blocks of glue code invoked by the scenario automation tool in response to text in the scenarios.
  • The scenario automation tool determines which step definition to call by matching the text in the specification against all expressions used when registering step definitions.
  • Scenario automation tools will signal an error if a step doesn’t match exactly one registration expression.
  • Most scenario automation tools support step definition registration expressions written using either Cucumber Expressions or regular expressions.
  • In addition to the step text, that is matched against the registration expressions, steps can also contain extra information (contained in docstrings and data tables) that can be passed to the step definition.
  • The development team can define Custom parameter types to ensure that step definition registration expressions can accurately model domain concepts.
  • Hooks are blocks of glue code that are called by the scenario automation tool, in response to predefined events in the execution process, such as before every scenario or after all scenarios have been run.
  • There are eight key principles of BDD automation, captured by the SUITABLE mnemonic.
  • Short cuts automation engineers should use appropriate mechanisms to accelerate scenario setup.
  • Understandable diagnostics reduce the cognitive load when the system does not behave as specified.
  • Isolated scenarios can be run repeatably no matter whether they are run on their own or as part of a larger set of scenarios.
  • Test-code quality is just as important as production code quality.
  • Atomic assertions ensure that all the available diagnostic information is provided whenever a scenario fails.
  • Business terminology should be used throughout the system—from business-facing documentation to implementation code.
  • Loose coupling is desirable to make code components testable on their own—without needing to always test through the UI or utilize resource hungry dependencies.
  • Evolving software using the iterative and incremental BDD approach requires fast, frequent feedback.
  • It is critical to choose a test automation strategy that maximizes confidence in the product while minimizing the time it takes to get feedback.
  • The test automation pyramid is a useful metaphor that can help you design your test automation strategy.

FAQ

What is the main goal of getting ready for scenario automation?It is to reduce the risk of automation by treating it as a series of experiments, so the team can learn, design, and validate an approach before automating everything.
Why do teams often run a proof-of-concept before automating all scenarios?A proof-of-concept helps the team gain confidence in an automation solution, explore recurring challenges, and avoid rushing into a full automation approach that may not be maintainable or effective.
What problems can cause scenario automation efforts to fail?Common causes include lack of automation skills, poor testability of the product, missing tools or environments, time pressure to skip automation, and uncertainty about designing a robust automation solution.
Why is skipping automation risky?Skipping or delaying automation creates quality debt. As the product grows, that debt can lead to lower quality, slower delivery, and more difficult maintenance.
What is a software design pattern in the context of scenario automation?A software design pattern is a general, reusable solution to a specific challenge occurring within a given context.
How should design patterns from automation work be documented?They should have a descriptive name and explain the problem they solve, where they are useful, how to apply them, and any important tradeoffs or examples.
What is a scenario automation tool used for?It turns scenarios into executable tests by matching scenario steps to automation code and running them through the chosen test execution environment.
What are glue code classes in scenario automation?Glue code includes step definitions, hooks, and custom parameter types. These are grouped into classes to connect the business-readable specification to the system under test.
What does the SUITABLE mnemonic represent?It stands for eight principles: Shortcuts, Understandable diagnostics, Isolated scenarios, Test-code quality, Atomic assertions, Business terminology, Loose coupling, and Evolving with fast feedback.
How should a team choose an automation strategy?The team should choose based on context, balancing speed, robustness, and confidence. They should consider which interface to automate through, whether to use real or stubbed dependencies, and avoid assuming that all scenarios must be automated through the UI.

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