
You write unit tests with AI by describing the behavior you want verified and letting the agent draft cases—including edge cases you might skip. The catch: tests are only useful if they'd actually fail when the code is wrong. AI is great at volume; your job is making sure that volume is meaningful.
Approaches, and where each fits:
- Inline test suggestions — best for quick coverage as you write functions.
- Test-generation prompts — best for backfilling tests on existing code.
- Verification-loop agents like Verdent — best when you want tests written and run in one flow.
Verdent ties tests into its verification loop: generated code is run against tests and patched until it passes, so testing is not a separate afterthought. Still, review the tests themselves—an agent can write a test that passes for the wrong reason.
The check that keeps you honest: if I broke this function on purpose, would these tests catch it? If not, they're decoration, no matter how green the run looks.
Have the agent draft tests for one real module, then try to break it. That exercise separates useful tests from busywork fast.
