liveBook · Manning

Approved outcome pattern

As explained in Effective Behavior-Driven Development

The Approved Outcome pattern represents a complicated expected result through an approved reference result that can be compared during testing.

Complicated results such as reports can be cumbersome to specify with simple assertions. The Approved Outcome pattern prints the result and compares it with an approved reference, making expectations easier to express and differences easier to see. section 16.4 section 16.5

Weekly sales report

A scenario checks a report of pizza sales by pizza and day. Printing the report into a readable text format allows the test to compare the complete result with an approved version; a changed sales value appears as a difference. section 16.4 section 16.5

Listing 16.16 Scenario containing an approved result
*** Features/Reporting.feature ***
Rule: Weekly report can be generated with daily and by pizza breakdown
  Scenario: Weekly sales report shows totals by pizza and day
    Given a normal week of operations with these pizza sales:
      | date       | BBQ  | Pepperoni | Margherita |
      | 2026-03-09 | $100 | $200      | $300       |
      | 2026-03-10 | $300 | $0        | $300       |
      | 2026-03-11 | $200 | $200      | $200       |
      | 2026-03-12 | $0   | $100      | $200       |
      | 2026-03-13 | $200 | $200      | $500       |
      | 2026-03-14 | $700 | $300      | $800       |
      | 2026-03-15 | $600 | $200      | $400       |
    And the restaurant owner is authenticated
    When the sales report is requested for the week beginning 2026-03-09
    Then the report should show:
      """
      * By Pizza
        * BBQ: $2100 (35%)
        * Margherita: $2700 (45%)
        * Pepperoni: $1200 (20%)
      * By Day
        * 2026-03-09: $600 (10%)
        * 2026-03-10: $600 (10%)
        * 2026-03-11: $600 (10%)
        * 2026-03-12: $300 (5%)
        * 2026-03-13: $900 (15%)
        * 2026-03-14: $1800 (30%)
        * 2026-03-15: $1200 (20%)
      * Total: $6000 (100%)
      """

See a scenario that states its expected weekly sales report as a structured text result. section 16.4

How Effective Behavior-Driven Development covers it

How deep it goes
Defines atomic approval comparisons, demonstrates report printing and diff-based assertions, and flags readability concerns.
Examples
Uses a printed weekly pizza-sales report and a changed value to demonstrate comparison and differences.
What you can do after
Evaluate structured outcomes by comparing printed results with approved references and inspecting reported differences.
How it connects
Connects approval testing with behavior-driven development, structured-result assertions, and regression testing.

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.