liveBook · Manning

Message persona pattern

As explained in Effective Behavior-Driven Development

A pattern that gives user-visible messages descriptive names so scenarios can refer to them without specifying their literal, potentially localized text.

A Message Persona replaces literal user-facing text in a scenario with a descriptive key. The key expresses the expected message, while resolution supplies the exact localized text for assertion. section 17.3

Listing 17.8 Scenario with a message key
*** Features/Ordering.feature ***
Rule: More than 4 large pizzas cannot be delivered as a single order
  Scenario: Five large pizzas are ordered
    When the customer places an order for 5 pizzas of size large
    Then the order should be rejected with message    #A
      ➥ [cannot-deliver-more-than-4-large-pizzas]

The scenario names the expected rejection message with a descriptive key instead of hard-coding its wording. section 17.3

When a message depends on scenario data, include the values with the key. For example, [cannot-deliver-too-many-large-pizzas,5] identifies a message that includes the number of pizzas. section 17.3

How Effective Behavior-Driven Development covers it

How deep it goes
Explains descriptive keys, language-specific resolution, custom parameter types, and parameterized message assertions.
Examples
Uses a large-pizza order rejection, showing literal, keyed, and parameterized message forms.
What you can do after
Apply it by naming expected user messages in scenarios and resolving exact text for assertions.
How it connects
Connects In-place Persona, feature scenarios, localization, and custom parameter types.

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.