r/softwaretesting • u/Strict_Illustrator95 • Jun 17 '26
Do you use per-test seed data for E2E/API tests?
Hey everyone,
I’m a web developer who likes testing, especially E2E and API tests. I often use tools like Postman, Cypress, and Playwright.
One thing I keep struggling with is test data management.
I’m currently leaning toward per-test seed data or scenario-specific seed data, instead of relying on one large shared test dataset.
For example, if I’m testing filtering for premium users, I want the test data to be created specifically for that scenario.
A simple example:
| id | name | createdDate | premium |
|---|---|---|---|
| 1 | John Doe | 2023-05-01 | true |
| 2 | Alice Smith | 2022-11-15 | false |
| 3 | Bob Johnson | 2023-03-20 | true |
| 4 | Charlie Brown | 2022-12-05 | false |
| 5 | Eve Davis | 2023-06-30 | true |
Then the filtering premium user test can clearly assert: “There should be exactly 3 premium users.”
I like this approach because:
- Each test scenario is easier to understand
- expected results are more explicit
- Tests are less affected by unrelated data changes
- A shared database state is less likely to create flaky tests
But I still find it painful to manage manually.
The problems I keep running into are:
- Many test data patterns. As the number of scenarios grows, the amount of seed data also grows.
- Schema changes break old seed data. When the database schema changes, old test data often needs to be updated as well.
I’m curious how other teams handle the test data management.
Do you use:
- per-test seed data?
- shared seed data?
- factories?
- fixtures?
- API-based setup?
- database snapshots?
- cleanup/reset after each test?
- separate test databases per run?
What workflow has worked best for keeping E2E/API tests reliable and maintainable?
3
u/XabiAlon Jun 17 '26
Only thing on our DB is logins and some basic data to get started.
Everything else from enabling settings for certain scenarios to CRUD is done via e2e.
The only thing that has changed in the DB in the last 7/8 years is migrations being added for schema.
1
u/BoxingFan88 Jun 18 '26
I would always try and create data as part of the test. Clean it up before the test runs and leave it in there when the test finishes
The advantage is, if you just run that test in isolation you know exactly what data it is writing and using. If you have a fault you can inspect exactly what is happening
Mass data sets in my experience are really difficult to reason with and it's more likely you will accidentally reuse data that another test is using. You can of course give them meta data to describe which test they belong to, but I think it's much more difficult
For API tests if you can creating the data using the APIs is the best option if it's possible
5
u/Asya1 Jun 17 '26
Seeding is the tits. Do it. Per test or suite really depends on your needs