liveBook · Manning

Terminology promotion pattern

As explained in Effective Behavior-Driven Development

A behavioral-test automation pattern that uses centralized custom parameter conversions to represent domain-specific terminology in specifications.

Behavioral-test steps sometimes need technical values that do not match the language a team uses to describe its work. The terminology promotion pattern uses custom parameter types to convert domain-specific terms centrally, keeping specifications readable and conversion logic maintainable. section 14.4

Pizza sizes

A scenario can specify a pizza size such as 14 inches. A custom parameter type maps that value to the corresponding PizzaSize enum, keeping the conversion in one place instead of embedding a manual mapping in the step definition. section 14.4

Listing 14.16 Define a pizza-size parameter type
*** 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 14"

*** Support/CustomParameterTypes.cs ***
[StepArgumentTransformation("(10\"|12\"|14\")", Name = "pizza-size")]
public PizzaSize ConvertPizzaSize(string pizzaSizeString) =>
  pizzaSizeString switch
  {
    "10\"" => PizzaSize.Small,
    "12\"" => PizzaSize.Medium,
    "14\"" => PizzaSize.Large,
    _ => throw new FormatException($"Invalid size: {pizzaSizeString}")
  };

*** StepDefinitions/OrderingStepDefinitions.cs ***
[When(
  "the customer places an order for {int} pizza(s) of size {pizza-size}")]
public void WhenTheCustomerPlacesAnOrderFor(int count, PizzaSize pizzaSize)
{
  var order = new OrderObjectMother()
    .WithItems(count, size: pizzaSize)
    .Build();
  ...
}

See the C# example defining a pizza-size parameter type and using it in a step definition. section 14.4

How Effective Behavior-Driven Development covers it

How deep it goes
Defines the pattern, explains its business-language and maintainability rationale, and demonstrates pizza-size conversion in C#.
Examples
Uses pizza sizes, geo coordinates, currency, yes-or-no Booleans, relative dates and times, and entity references as conversion examples.
What you can do after
Apply the pattern by defining custom parameter conversions for domain-specific terms used in behavioral-test steps.
How it connects
Connects custom parameter types with step definitions and the Business language principle.

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.