Fix 1 of 2
Have AI write the tests, then you check what they actually assert
Coding agents write good first-pass unit and integration tests in your existing style. Your job shifts to checking the cases and assertions are meaningful.
- 1Point the agent at the file or function and an existing test file to copy the style from.
- 2Use the prompt below; ask for edge cases explicitly.
- 3Run the tests and make sure at least one fails if you break the code on purpose.
- 4Delete tests that only check mocks or repeat the implementation.
Write tests for [FILE OR FUNCTION] using [TEST FRAMEWORK], following the style of [EXISTING TEST FILE]. Cover the main behavior, edge cases ([EMPTY INPUT, LIMITS, ERRORS]), and any bug fixed recently in [AREA]. Prefer real objects over mocks where it is cheap. Run the tests, fix failures in the tests (not in the code), and list any behavior that looks like a bug instead of changing it.
Tools: Claude Code, OpenAI Codex, Cursor, GitHub Copilot agent mode or Devin Desktop (ex-Windsurf)