When a later step needs information established by an earlier step in a different class, a shareable scenario context lets both steps access it. The shared information belongs to that scenario’s execution, so it cannot affect another scenario’s outcome. section 13.2 section 13.5
An authenticated customer places an order
An authentication step records Rebecca’s name in an AuthenticationContext. An ordering step can then use the authenticated customer to place an order, and subsequent steps can refer to that customer without repeating the name. section 13.2
Choose what to share with care:
- Share context across classes when a step depends on information introduced earlier elsewhere in the scenario. section 13.2
- Keep data in a separate context class only when multiple glue-code classes need it; a single-class use does not yet require that move. section 13.2
- Consider storing a derived object instead of an identifier to avoid a later lookup, while weighing the risk of stale data if another service changes the object. section 13.2
