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

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

- Source: Trial: high-attention AI launches and demos
- Published: 2026-10-27T07:07:36.000Z
- Bad Influence: https://badinfluence.news/items/end8ukxit4tjfvzkfjdl6xpkx
- Original: https://x.com/dmokafa/status/2114977298122244116

## Summary

A 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. The post also argues teams should measure how many bugs AI tests catch rather than how many tests they write.

## Post

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.

## Quoted post @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!

https://x.com/shcallaway/status/2106142042405453879
