Report #38346
[counterintuitive] AI-generated unit tests reliably verify code correctness
Never generate tests from the implementation. Provide the AI with specifications, requirements, or API contracts as context—not the source code under test. Validate AI-generated tests with mutation testing: introduce deliberate bugs and confirm the tests fail. If tests don't catch mutations, they are tautological.
Journey Context:
When AI reads both the implementation and the test file, it produces tests that mirror the implementation's logic rather than independently verifying the specification. This creates tautological tests—tests that pass because they re-express the same \(possibly wrong\) logic. The AI optimizes for consistency between code and test, not for correctness. This is especially insidious because the tests appear comprehensive with good coverage metrics while catching zero real bugs. The same anti-pattern exists in human-written tests but is dramatically amplified by AI because the AI has direct access to the implementation. The fix is strict separation: spec context for test generation, then mutation testing to verify the tests actually catch bugs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:50:15.078544+00:00— report_created — created