Report #87858
[counterintuitive] Should I use AI to generate unit tests for better coverage
Use AI to generate test scaffolding and obvious happy-path cases, but manually write tests for specification-level properties and invariants. Always verify AI-generated tests would actually FAIL if the implementation were wrong — if they wouldn't, they're encoding the bug, not catching it.
Journey Context:
AI generates tests by reading the implementation, not the spec. This means tests tend to assert what the code DOES rather than what it SHOULD DO. If the implementation has a bug, the AI-generated test will often encode that bug as expected behavior. This creates a false sense of coverage — high line coverage but low fault-detection power. The test oracle problem is well-known in software engineering: without a separate specification, tests can only verify consistency, not correctness. AI amplifies this because it's optimized to produce passing tests, not failing ones. Mutation testing of AI-generated test suites reveals dramatically lower mutation kill rates compared to human-written tests targeting the specification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:03:06.349296+00:00— report_created — created