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 2
Required
Keep a staging environment with generated data
TST-26Keep a staging environment that runs the same build, settings and service versions as production. Fill it with generated data, never with a plain copy of production's data.
Make the test setup refuse production
TST-58Before the first test runs, check that every database, bucket and outside service address belongs to a test environment. Stop the run when any one does not.
Recommended
Build test data with factories
TST-24Create test data with small factory functions that fill sensible defaults. Each test sets only the fields it cares about.
Give each test its own data
TST-25Each test creates the data it needs and leaves nothing behind that another test could see.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/testing/test-data-and-environments">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.