liveBook · Manning

Test data

As explained in BDD in Action, Second Edition

Test data is data prepared or managed to establish conditions for executing and verifying software tests.

Test data establishes the known initial and final states needed to execute and verify a scenario. Effective scenarios describe only data that influences the behavior under test, hiding incidental details. section 7.6.6 section 8.5

Useful practices for managing test data include:

  • Set up databases, permissions, records, files, and external resources quickly, precisely, and automatically before a scenario. section 8.5 section 8.6
  • Represent recurring data through named personas whose details can live in JSON-like files or an initialized test database. section 9.2.1
  • Separate test data from UI selector logic so changing either does not require duplicating or rewriting unrelated automation. section 11.1
  • Remove columns that do not affect the business rule, keeping scenarios understandable to the whole team. section 7.6.6

Distance-based hotel search

Prepare three available Paris hotels with distances of 3.2, 6.9, and 12.5 km; searching within 10 km should return only the first two. The data makes both the starting state and expected result explicit. section 7.6.6

Scenario: Search for available hotels by distance
  Given Bindi needs to make a business trip to Paris
  And the following hotels have available rooms:
    | Hotel Name | Location | Distance from center |
    | Ritz       | Paris    | 3.2                  |
    | Savoy      | Paris    | 6.9                  |
    | Hilton     | Paris    | 12.5                 |
  When Bindi searches for a hotel within 10 km of Paris
  Then she should be presented with the following hotels:
    | Hotel Name | Location | Distance from center |
    | Ritz       | Paris    | 3.2                  |
    | Savoy      | Paris    | 6.9                  |

Inspect a complete scenario showing prepared hotel data, a distance constraint, and the filtered expected result. section 7.6.6

How BDD in Action, Second Edition covers it

How deep it goes
Explains focused scenario data, persona storage, automated setup, hooks, and separation from UI selectors.
Examples
Uses hotel searches, Frequent Flyer credit tables, named personas, JSON-like files, databases, and automated environment setup.
What it assumes
Assumes scenarios and automated acceptance tests, while teaching how to define, store, prepare, and isolate their data.
What you can do after
Apply it via personas and hooks to initialize precise test states and maintain readable, reusable automated acceptance tests.
How it connects
Connects test data with executable specifications, acceptance tests, personas, test environments, hooks, databases, and UI automation.

Also explained in

Compare how 3 books explain test data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.