AI-generated tests are terrible. Blame the developers.
AI writes bad tests because it learned from us.
Here are 8 tips to make your AI agents write better tests:
- Avoid mocks whenever possible
- Use Testcontainers for integration tests
- Don't couple tests to code structure. Couple to public APIs
- Reproduce a bug in a failing test before fixing it
- Keep logic out of the tests
- Run mutation and property-based tests to find missing tests
- Use Playwright MCP to test real user flows
- Assert behaviors from the user point of view
Give this list to your AI agent and make these rules part of your harness.
I just launched my new course teaching my full AI agent testing workflow.
Get $100 off today: http://aiagentengineer.dev
Stop measuring how many tests AI writes.
Start measuring how many bugs they can catch.
