Test data and environments
Build test data in code, give each test its own, and test on an environment that matches production. Never copy personal data into tests.
- Required 2
- Recommended 1
Required
Give each test its own data
RequiredEach test creates the data it needs and leaves nothing behind that another test could see.
Keep a staging copy with fake data
RequiredKeep a staging environment that runs the same build, settings and service versions as production, with fake data.
Recommended
Build test data with factories
RecommendedCreate test data with small factory functions that fill sensible defaults. Each test sets only the fields it cares about.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/test-data-and-environments.