Report #12762
[research] LLM writes unit tests that assert incorrect, hallucinated behavior \(e.g., asserting a function returns a string when it returns an int\)
Require the agent to execute the existing codebase or read the source code to infer actual return types and behaviors before writing assertions; never generate tests based solely on the function name or docstring.
Journey Context:
When generating tests for a stub, LLMs assume the implementation works as described, which might be wrong. If the implementation is buggy, the LLM might write tests that pass against the buggy code. Grounding test generation in runtime execution \(e.g., running type\(\) or capturing actual outputs\) ensures tests validate real behavior, not hallucinated behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:51:05.577812+00:00— report_created — created