liveBook · Manning

Test data management

As explained in Effective Behavior-Driven Development

The practice of defining and maintaining the data provided to the system under test in software testing.

Two scenarios can give different results if they start with different data—or interfere with each other if they change the same shared database. Test data management (TDM) is the practice of defining and maintaining the data provided to the system under test. For repeatable results, each scenario needs an effectively identical starting state, called a baseline. section 18.1

Choose a baseline that fits the database or service:

  • Clean start: begin empty. Each scenario must provide the data it needs. section 18.1
  • Seeded: begin with common reference data and default entities. Scenarios add only what their behavior requires; this is recommended when feasible. section 18.1
  • Snapshot: begin with a richly populated dataset, such as an anonymized production snapshot or curated data. This can help when direct data insertion or manipulation is unsuitable. section 18.1

A baseline may still need scenario-specific entities. If automation can freely change the service state, it can insert exactly what a scenario needs. Otherwise, it can query the baseline for entities matching stated criteria or use entities manually identified in it. Querying needs a suitable API and fails when no entity matches; both querying and hardcoding depend on the baseline containing suitable data. section 18.1 section 18.7

Figure 18.1 Conflicting modifications when running tests in parallel using a shared database

Parallel scenarios can make conflicting changes when they use a shared database. Resetting a baseline supports repeatability, but running against an external service also requires an isolation strategy, such as serial execution, resource pooling, or exclusive data partitions. section 18.1 section 18.7

How Effective Behavior-Driven Development covers it

How deep it goes
Distinguishes three baselines and three scenario-data approaches, then relates external-service testing to isolation, repeatability, and performance.
Examples
Contrasts empty, seeded, and snapshot baselines and depicts conflicting changes from parallel tests sharing a database.
What it assumes
Defines test data management and baselines while using scenarios, databases, and automation code as working context.
What you can do after
Practice/perform it by choosing a baseline and an Insert, Query, or Hardcode approach suited to the service.
How it connects
Connects test data management to scenario isolation, database state, external services, and parallel test execution.

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.