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
