liveBook · Manning

Templated data persona pattern

As explained in Effective Behavior-Driven Development

A pattern that creates persona definitions from reusable templates with scenario-specific changes.

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 portions

A 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

How Effective Behavior-Driven Development covers it

How deep it goes
Explains customization through sales-record filtering and JSON setting overrides, using step definitions rather than requiring a templating library.
Examples
Uses a sales-traffic file with truffle sales excluded and a typical JSON configuration with selected settings changed.
What you can do after
Apply it via a templating library or hand-crafted step definitions to customize one external definition for multiple scenarios.
How it connects
Connects external persona definitions to feature files, scenario data tables, step definitions, and configuration templates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.