Skip to content
View original post on X: Daniel Moka⚡
Published
36/100

AI writes bad tests; eight tips for better agent-written tests

AIA post argues that AI-generated tests are poor because AI learned from developers' tests, and lists eight rules for agents, such as avoiding mocks, using Testcontainers, and testing public APIs. The author is promoting a $100-off course on the workflow.
Daniel Moka⚡Verified on X
@dmokafa
View on X

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.

Sherwood@shcallaway
We deleted 800k lines of unit tests from the @sazabi monorepo earlier this week. Three hypotheses: 1- Unit tests "lock-in" slop code by making it hard to change or remove 2- Unit tests slow down dev cycles by making your agent do more work locally and by increasing CI times 3- Unit tests waste money by making your agent generate more tokens and by adding useless CI runs Will report back soon with the results!
View quoted post on X
Source details

Daniel Moka⚡ · x.comPublished · added here

Original title: AI-generated tests are terrible. Blame the developers.