A team may need several scenarios with almost identical sales data. Making a separate, hand-crafted data file for each one creates maintenance work, especially when the differences are hard to spot later. A templated data persona keeps a reusable external definition and states only what each scenario changes. section 17.5 section 17.6
The template holds the typical case; the scenario names the exceptions. This lets domain experts help shape realistic data without requiring them to maintain a growing collection of nearly identical definitions. The exception should be visible in the scenario or documented by a template placeholder. section 17.5
Listing 17.13 Scenario uses a customized version of the simple sales data
*** Features/Reporting.feature ***
Rule: Ingredient usage report can be generated for a week
Scenario: No sale of a particular ingredient on a week
Given sales traffic from "realistic-traffic.csv" with #A
| exclude section |
| truffle sales |
And the restaurant owner is authenticated
When the ingredient usage report is requested for the week
➥ beginning 2026-03-09
Then the report should contain "truffle" usage as 0 portionsA sales-traffic scenario reuses an external CSV file but excludes its truffle-sales section. The expected report then shows zero portions of truffle usage. section 17.5
Customization need not involve a templating library. A step definition can load an external file and filter its records. For a JSON configuration, a step definition can instead load a typical configuration and use a scenario data table to change the one or two settings that matter. section 17.5
Keep the shared definition useful over time:
- Make the scenario’s changes clear rather than hiding them in another large file. section 17.5
- Keep external definitions alongside the feature files and version them together. section 17.6
- When changing a configuration during execution, log the full resulting configuration to help investigate failures. section 17.5
