Chapter 17: Dramatis personae patterns for clear naming of concepts
The introduction explains why clear, domain-based names for business concepts make scenarios easier to read and discuss.
After this chapter you will be able to
- Clear Names for Business Concepts. Explain why scenarios give entities and concepts descriptive, unambiguous names rooted in business terminology, and how a shared product glossary supports those names.
- Named data personas. Explain how a meaningful persona name can stand for a data set or structure representing a particular situation, and how the book uses “persona” for both data personas and user personas.
- Persona definition purpose. Describe what a persona definition provides and why both automation code and human stakeholders may need it.
- Scenario data locality. Explain where data persona definitions may be placed and why details essential to a scenario’s meaning must remain in the scenario itself.
- Names for precise data. Explain why a scenario may give an arbitrary name to a precise set of data rather than identify an existing entity by a property. Describe how names such as A, B, and C make orders unambiguous even when their displayed order changes.
- Named order lookup. Trace how the order example connects a name in a scenario to an order used by later steps. Explain the role of scenario context and the extended order custom parameter type.
- Feature Background persona reuse. Explain how defining named data personas in a feature’s Background supports multiple scenarios while leaving each scenario explicit about the data it uses. Distinguish when a Background persona is typically created from when a persona defined in a Scenario is created.
- Message Persona resolution. Explain why a scenario can use a descriptive message key instead of literal text, and how automation uses that key to assert the message for the selected language.
- External Persona use case. Explain when to use an External Persona rather than define data in a feature file: the data is too large to include there, and its details are not needed to understand the scenario.
- Verifiable external persona outcomes. Explain why results based on a large external persona need a way for readers to validate them, and describe the options the section gives: assert a result property, use an approved outcome to detect changes, or keep expert-calculated expected values with the input data.
- Templated Persona purpose. Explain when to use the Templated Persona pattern and why a shared template can be preferable to a separate external persona definition for every scenario.
- Scenario specific template changes. Describe how a scenario can specify limited changes to shared external data, using the sales-data or JSON-configuration example.
What it builds on
- Documenting the domain (chapter 10) · The product glossary as documentation of domain concepts.
- Introduce and Refer pattern: separating introduction and reference (chapter 13) · Introducing and referring to entities relevant to a scenario.
- Custom parameter types (chapter 12) · Custom parameter types in scenario automation.
- Shareable Scenario Context pattern: sharing data between step definitions in different classes (chapter 13) · Sharing scenario data between step definitions.
- Moving shared context into a background (chapter 9) · The concern that Background steps can make scenarios harder to understand on their own.
- Context Shortcut pattern: bring the application to the expected state (chapter 16) · Creating the state needed by a scenario through a Context Shortcut.
- Step definitions (chapter 12) · Step definitions used in scenario automation.
- Approved Outcome pattern: atomic handling of complex assertions (chapter 16) · The Approved Outcome pattern referred to by the example's approved result.
Section by section
Introduction
The introduction explains why clear, domain-based names for business concepts make scenarios easier to read and discuss.
- Clear Names for Business Concepts: Explain why scenarios give entities and concepts descriptive, unambiguous names rooted in business terminology, and how a shared product glossary supports those names.
Why it matters: A shared name helps everyone discuss the same concept without making scenarios harder to read.
Key terms: business concepts, business domain terminology, product glossary, personas
17.1 Personas
This section introduces personas as meaningful names for scenario data and explains how persona definitions keep scenarios understandable.
- Named data personas: Explain how a meaningful persona name can stand for a data set or structure representing a particular situation, and how the book uses “persona” for both data personas and user personas.
Why it matters: A shared, meaningful name lets readers recognize the situation a scenario describes. - Persona definition purpose: Describe what a persona definition provides and why both automation code and human stakeholders may need it.
Why it matters: The same specification data helps automation create the intended situation and helps people interpret it. - Scenario data locality: Explain where data persona definitions may be placed and why details essential to a scenario’s meaning must remain in the scenario itself.
Why it matters: Keeping crucial details close to the scenario makes its meaning clear without sending readers to another source.
Key terms: persona, data persona, user persona, glossary, persona definition, feature file, Background blocks, locality of reference, persona definitions
17.2 In-place Persona pattern: persona definitions in feature files
The section explains how the In-place Persona pattern gives small, feature-local data sets names that scenarios can use without repeating their details.
- Names for precise data: Explain why a scenario may give an arbitrary name to a precise set of data rather than identify an existing entity by a property. Describe how names such as A, B, and C make orders unambiguous even when their displayed order changes.
Why it matters: A stable name lets readers follow which data a scenario means without depending on its position in a list. - Named order lookup: Trace how the order example connects a name in a scenario to an order used by later steps. Explain the role of scenario context and the extended order custom parameter type.
Why it matters: This connects readable scenario names to the specific orders that automation must act on. - Feature Background persona reuse: Explain how defining named data personas in a feature’s Background supports multiple scenarios while leaving each scenario explicit about the data it uses. Distinguish when a Background persona is typically created from when a persona defined in a Scenario is created.
Why it matters: Shared definitions reduce duplication without hiding which sample data each scenario selects. - In-place persona boundaries: Describe when a persona definition belongs in a feature file and why the pattern is unsuitable for large definitions or personas needed across several feature files.
Why it matters: Choosing the right scope keeps the feature useful as readable, verifiable documentation.
Key terms: In-place Persona pattern, persona definition, scenario context, order custom parameter type, step definition, Background, data persona definitions, feature file, persona definitions
17.3 Message Persona pattern: asserting user messages
This section explains how Message Personas let scenarios name user messages by intent while automation resolves and asserts the appropriate text.
- Message Persona resolution: Explain why a scenario can use a descriptive message key instead of literal text, and how automation uses that key to assert the message for the selected language.
Why it matters: Scenarios can remain readable when message wording changes or the interface supports multiple languages. - Parameterized message assertions: Describe how a scenario can assert a message whose text includes a changing value, such as the number of pizzas ordered.
Why it matters: A stable message name can still support assertions about text containing scenario-specific values.
Key terms: Message Persona, descriptive key, selected language, custom parameter type, parameterized messages, parameter placeholder, message persona’s name
17.4 External Persona pattern: load test data from external sources
The section explains how to keep large persona data outside a feature file while making it available to scenarios and keeping the outcomes verifiable.
- External Persona use case: Explain when to use an External Persona rather than define data in a feature file: the data is too large to include there, and its details are not needed to understand the scenario.
Why it matters: It keeps a scenario readable even when realistic verification needs a large data set. - Persona file and scenario integration: Describe how the example scenario uses an external persona: its Given-step definition loads data from a CSV file and prepares it for the application. Explain why the file must be kept and versioned with the feature files.
Why it matters: A scenario cannot reliably use or explain its external data if that data becomes separated from the specification. - Verifiable external persona outcomes: Explain why results based on a large external persona need a way for readers to validate them, and describe the options the section gives: assert a result property, use an approved outcome to detect changes, or keep expert-calculated expected values with the input data.
Why it matters: A passing scenario is useful only if its expected outcome has a meaningful basis for verification.
Key terms: External Persona pattern, In-place Persona pattern, persona definition, feature file, Given step, step definition, CSV file, external persona definition, feature files, approved result
17.5 Templated Persona pattern: customizing external data sets
This section explains how to customize shared external persona data for scenarios that differ in limited ways, while avoiding duplicated data sets.
- Templated Persona purpose: Explain when to use the Templated Persona pattern and why a shared template can be preferable to a separate external persona definition for every scenario.
Why it matters: A shared template makes differences between scenarios easier to express without maintaining many near-duplicate data files. - Scenario specific template changes: Describe how a scenario can specify limited changes to shared external data, using the sales-data or JSON-configuration example.
Why it matters: Scenarios can state only the variations relevant to their behavior while reusing the rest of a realistic data set. - Multi step filtering timing: Explain why specifying one data set and its filters in separate sequential steps complicates loading, and describe the alternatives given.
Why it matters: The automation must wait until it has the complete filter specification before loading the data.
Key terms: Templated Persona pattern, External Persona pattern, external persona definition, step definition, data table, template, filtering, Given, But, closing step
17.6 Summary
Concepts explained in this chapter
- test personaA description of a named business concept or entity used to illustrate expected system behavior.
- in-place persona patternA persona pattern in which a scenario refers directly to a named representation of a domain or interface concept at the point where it appears.
- templated data persona patternA pattern that creates persona definitions from reusable templates with scenario-specific changes.
- external data persona patternA pattern that stores persona definitions outside feature files so they can be managed separately and reused.
- message persona patternA pattern that gives user-visible messages descriptive names so scenarios can refer to them without specifying their literal, potentially localized text.
- personaA representative user profile or named representation of a situation used to discuss expected behavior.
- data personaA named data set representing a particular situation, with a description of data attributes for key inputs, preconditions, and outputs referenced by scenarios.
- StepArgumentTransformation attributeA Reqnroll attribute that registers a method to transform captured text into a value for a step definition.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
