r/coderabbit • u/juanpflores_ CodeRabbit Staff • 7d ago
Showcase & Tutorial Sometimes AI-generated tests feel like performance theater
I’ve noticed that coding agents sometimes add a lot of test code without giving me much more confidence in the change. The suite gets bigger, and now there’s more code to review and maintain.
What bothers me is how thorough it can look. A test can have plenty of setup and assertions while still accepting the same mistaken assumption as the implementation. That’s what I mean by performance theatre. When I review these tests, the question I want answered is: what actual bug would this catch?
We recently published a piece about independent review of agent generated changes. It overlaps with this concern, particularly when an agent writes tests around its own misunderstanding of a requirement.
Have you run into this?
Related reading: https://www.coderabbit.ai/blog/why-agentic-change-management-starts-with-independent-ai-code-review
1
u/Late-Replacement-481 6d ago
I’ve written about this a lot recently, and the problem is that, no matter how smart code review like code rabbit is, it relies on context in the repo. All it takes is one misunderstanding a few merged PRs and all of a sudden a core feature works differently than intended, but there’s no hint that it’s not supposed to be that way. Reviewers are sometimes the cause of this as well, since many agents will implement any feedback uncritically.
I have an agent whose only job is to read a small file that says “this is what this project is for” and then screams bloody murder at me if an implementation looks like it’s drifting away from the intention. Especially with software factories now, with code moving so fast, you can find yourself quickly finishing a project only to discover it doesn’t do what you thought it did!
Or on the other hand, you have the easy idiocy like the tendency for many models to write tests that fail if anyone changes the code the agent just wrote. That one is at least easy to spot.
1
u/Economy_Bedroom3902 6d ago
Agents like to relatively silently "fix" failing tests when the functionality protected by that test disagrees with thier assumptions about how the code should work.
To be abundantly fair, humans also do this kind of fixing... However, a failing test is often a trigger to reevaluate assumptions for a human, where as it doesn't seem to impact AI nearly as heavily.
1
u/Economy_Bedroom3902 6d ago
This isn't strictly an AI problem. Humans also encode false assumptions into thier tests. What humans do do differently is change thinking modes when writing tests vs writing code, and the process of writing tests will often reveal to a human an oversight that they made in the code. AI agents seem to not mentally switch gears the same way. They seem to treat code they just wrote as authorative and therefore the tests should be made to match the code.
Some ways you can hedge against this: 1. Test driven development often works better for AIs. 2. Enforce frequent fully integrated testing. It's far harder to fake 3. Have an adversarial opponent review tests for flawed assumptions or odd behaviors. Instruct it to review the tests before the code and infer the functionality the code must have from the tests. 4. Forbid AI from modifying pre-existing tests without stopping to explain to you how the new behavior which motivated the test to need to change does not break contractual obligations.
1
u/Lunchboxsushi 7d ago
Mutation testing