Overview

20 Staging patterns for adapting test execution

This chapter explains how BDD teams can adapt test execution to match the many environments, resources, and deployment variants a system may support. Rather than treating configuration as a narrow concern, it presents it as a broad part of scenario execution: local runs, CI/CD pipelines, different browsers, real or stubbed dependencies, and even multiple product variants may all require different settings. The central idea is to keep these choices manageable by separating configuration concerns from the rest of the automation code.

One key approach is to centralize configuration access in a dedicated provider that hides the details of where values come from, such as JSON files, environment variables, or command-line arguments. As the number of settings grows, a flat list of properties can become unwieldy, so the chapter recommends organizing configuration into typed sections that mirror the structure of the settings. This makes it easier for automation code to consume configuration consistently while still allowing sensible defaults and simple overrides in different execution contexts.

The chapter then shows how configuration can influence both automation behavior and scenario design. Parameterized execution lets the same scenarios run with different test parameters to increase coverage, such as switching between stubbed and real dependencies or running across different browsers, though it warns that this can add time and cost. Parameterized scenarios go a step further by making the specification itself configurable, using placeholders and custom parsing so that the same feature files can validate different deployment settings and terminology. Together, these patterns help teams test not just one system, but the many forms that system may take in real use.

Overriding test configuration values
Overriding test configuration values
A schematic showing deployment and validation of one WIMP configuration
A schematic showing deployment and validation of one WIMP configuration

Summary

  • Environment configuration controls what systems and resources tests should use for each environment that it runs in.
  • Test parameters control how a test should be executed.
  • Test configuration values should usually have a default value. Overrides can be provided in configuration files, in environment variables, as console arguments, or as required.
  • The Test Configuration pattern suggests that the mechanism by which configuration data is obtained should be encapsulated and the values set should be available from a central location.
  • In most commercial systems, there are so many test configuration settings that they should be partitioned into sections, with each section available from a separate class instance.
  • Many development platforms provide libraries to facilitate the processing of configuration data.
  • The Parameterized Execution pattern ensures that whenever the automation code needs to choose one of several options, that decision should be based on a test configuration setting.
  • A test configuration setting may not be relevant to every scenario, so it is not always necessary to rerun every scenario when changing a single test configuration setting.
  • Not all scenarios illustrate behaviors that are supported by every possible value of a test configuration setting, so don’t run scenarios that aren’t supported by the current test configuration.
  • Tags can be a useful way to indicate which test configuration sections and values are relevant to a scenario.
  • The Parameterized Scenario pattern supports the testing of software factories using test configuration settings.
  • Software factories produce application variants according to externally defined, end-user requirements.
  • For software factories, some elements in a scenario might vary depending on the end-user requirements. To test these variations with different values, they must be identified in the scenario (using placeholders) and the value determined by accessing test configuration settings when the scenario executes.

FAQ

What is the main purpose of the staging patterns in this chapter?The staging patterns help adapt BDD test execution to different environments, external resources, and deployment configurations so the same system can be tested flexibly and effectively.
What is test configuration in the context of BDD scenario execution?Test configuration is the set of settings that control how scenarios run, including environment-specific resources like base URLs, database connections, external service locations, and execution parameters such as browser choice.
How can test configuration values be specified or overridden?Common ways include configuration files, environment variables, and console arguments. A typical approach is to store defaults in a file and override selected values with environment variables in CI/CD or special test runs.
Why are environment variables often recommended for overriding configuration?Environment variables are widely supported across platforms and CI/CD systems, making them a flexible and portable way to override a small number of settings without changing configuration files.
What is the Test Configuration Provider pattern?The Test Configuration Provider pattern encapsulates the logic for loading and exposing configuration values so that automation code does not need to know whether values come from files, environment variables, or other sources.
Why might a test configuration provider expose hierarchical sections instead of flattened properties?As configuration grows, hierarchical section objects such as Database or PaymentGateway make the code cleaner, more maintainable, and better organized than exposing every setting as a separate top-level property.
What is Parameterized Execution in BDD automation?Parameterized Execution means running the same BDD scenarios multiple times with different test parameters to extend coverage, such as using different browsers, database types, or external service versions.
When should you be cautious about introducing parameterized execution?You should be cautious when extra runs would significantly increase execution time, infrastructure cost, or maintenance complexity, especially if only a small number of scenarios benefit from the variation.
How should scenarios be tagged for parameterized execution?Tagging depends on how broadly the parameter applies. If only some scenarios are affected, tag those scenarios and filter by tag. If some scenarios are unsupported by a parameter value, use exclusion tags like negative support tags in the execution filter.
What is the Parameterized Scenario pattern used for?The Parameterized Scenario pattern is used when the scenario text itself needs to vary with deployment configuration, such as currency symbols or terminology differences, and the steps or custom parameter types resolve those configuration-dependent placeholders during execution.

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