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
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.
Effective Behavior-Driven Development ebook for free