liveBook · Manning

In-place persona pattern

As explained in Effective Behavior-Driven Development

A persona pattern in which a scenario refers directly to a named representation of a domain or interface concept at the point where it appears.

When a scenario involves several orders, “the order” can become ambiguous. The in-place persona pattern gives an entity or business concept a name and defines what that name means in the feature file. Later steps can refer to it without repeating its details. section 17.2 section 17.6

Cancel one named order

A scenario defines orders A, B, and C with their statuses, then says the customer cancels order B. The expected order list shows B as Cancelled while A and C retain their statuses. The names make the action and its result unambiguous. section 17.2

Put a persona definition in its Scenario when it serves only that case. Put it in Background when several scenarios in the feature file need the same definition. For example, named weekly sales-traffic samples can be defined once and selected by reporting scenarios, avoiding repeated tables. section 17.2 section 17.6

Keep the name useful to the people discussing the behavior:

  • Name business concepts as well as entities. Defining “approximately” as a range lets scenarios state an acceptable temperature without restating the range. section 17.2
  • Keep definitions in the feature file while they remain readable there. If they become too large, an external persona definition is an alternative. section 17.6

How Effective Behavior-Driven Development covers it

How deep it goes
Explains Scenario and Background placement and illustrates named-order lookup through step definitions and shared context.
Examples
Uses named orders in a cancellation scenario, reusable weekly sales-traffic samples, and an “approximately” temperature range.
What it assumes
Assumes familiarity with feature files, scenarios, and Background blocks while explaining how to name their entities and concepts.
What you can do after
Practice defining a named persona in a Scenario or Background and referring to it in subsequent steps.
How it connects
Connects persona definitions to feature files, Background blocks, shared scenario context, and external persona definitions.

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.