test-data
Installation
SKILL.md
Test Data Management
Apply these rules when deciding where to create test data, how to clean it up, and how to keep parallel runs from colliding.
Decision Framework: Where Should Test Data Live?
| Scenario | Strategy |
|---|---|
| Simple record (1–2 fields, no relationships) | Create in the test, clean up in finally |
| Complex record (multiple relationships, prerequisites) | Precreate in the test database project (deployed with the DB), reference by stable description in the test |
| Read-only validation (asserting on existing data shape) | Use existing precreated data, no cleanup |
| Specific data state (e.g., a closed order, an inactive user) | Seed via API or SQL before the test, clean up after |
The rule of thumb: the more complex the setup, the more it belongs outside the test body. A long Given section obscures what's actually being tested.
The try/finally Cleanup Pattern
Tests that modify data must clean up. Use try/finally, never try/catch: