Did Your AI Agent Skip or Delete Tests to Pass CI?

A green build won't show skipped, deleted, or slower tests. Learn what to compare between CI test runs when AI writes your code.

Did Your AI Agent Skip or Delete Tests to Pass CI?

With more organizations using AI to generate code for their applications, we're seeing more pull requests opened on our codebase every single day. If you're a developer or tester, you've likely felt the increase coming through. And these aren't tiny, one-off changes in these pull requests, either. As an example, I just finished an AI coding session where the agent spawned a new pull request that added, deleted, and modified 32 files. We'd have these pull requests maybe a handful of times in a week before, but we're now seeing them pop up multiple times a day. We can't be expected to reasonably check every single thing that changed.

In my AI-generated pull request, the description says it refactored one service and fixed a few automated tests along the way. As part of our workflow, the required CI checks were all green, and skimming through the diff, everything looks good to me. However, can I be certain that the AI-generated tests are doing the right thing? The CI run only tells me that the tests are passing, but it doesn't tell me exactly what the AI agent did. I'd need to really dig into the changes made in the pull request, and with all the changes in this and many other pull requests waiting in the repo, ain't nobody got time for that.

A Passing Build Only Tells You Part of the Story

A single passing build only tells you the story of one test run in isolation, but it doesn't tell you how it compares to previous test runs, which is where some of the most useful info is found. I've found a lot of poor decisions made by AI agents that were hidden in between the pile of changes thrown into a single pull request. I've seen important tests marked as skipped and even completely deleted because one of the changes caused them to fail and the AI agent didn't attempt to fix it. I've also noticed many tests suddenly taking up to five times longer to run compared to before because the agent added some unoptimized database calls to the initial setup. None of these issues show up when the CI cheerfully marks a build as passed.

This isn't something new that's being caused by low-quality or rogue AI agents. We've always had to deal with skipped or deleted test cases because someone couldn't get them to work, or new code that accidentally introduced a change that bogged down the entire test suite. The difference between then and now is the quantity of what developers and testers have to manage now. As alluded to earlier, codebases everywhere are getting slammed with more commits and pull requests, and it's gotten to a point where most team members can't remember what the test suite looked like even an hour ago.

Out of the box, most CI setups only tell you whether the test suite passed or failed. Of course, we want to know this information, but it doesn't give you a clear picture about the changes introduced in the CI run. It doesn't tell you that a previous test run failed due to a flaky test and the current run passed despite having no modifications done to the codebase. It won't mention that the latest commit deleted 10% of the test suite because the coding agent opted to have the test suite passing instead of trying to fix what was breaking.

We didn't have these details in the past either. However, developers and testers could at least know the reasons behind a CI test run because we would be the ones making the changes. We knew what tests were added, removed, or modified, and we knew why we did it or someone could ask in a code review. Right now, we have less of that context available. An AI agent can have dozens or hundreds of changes to the test suite, and unless explicitly instructed to do so, they won't give you their reasoning behind the modifications.

Why AI-Generated Tests Make This Harder

I'm sure most people reading this are actively using AI in their daily work (or are bots spawned by AI tools, so it might still apply). You've likely noticed that coding agents are very good at hitting whatever goal you give them, even when the way they get there defeats the purpose. This is known as reward hacking. Tell an agent to make the build pass and that's exactly what it'll do, good engineering practices be damned.

For test suites, that means getting a passing build even if it makes the codebase weaker by gutting the tests that protect it. If that means editing a test so that it passes even though it now asserts something completely unimportant, or nuking tests that would cause the build to turn red, the AI agent doesn't care. All they see is that the test suite is passing, and that's all that matters.

Another way that AI makes life more difficult for us nowadays is the sheer volume of changes introduced in one go. Coding agents love to add dozens of tests and to over-complicate them with multiple assertions per test case. In one example, I added a two-line method to a codebase that simply did a check and returned a boolean (true or false). I asked the AI agent to add test coverage for this while I worked on something else, and it came back with 15 new test cases for that single method. It hallucinated assertions for edge cases that would never occur in the code, and it began inserting a lot of data into the test database, which added a few seconds of runtime to the test suite. Without paying close attention, these changes would have slipped in undetected and led to a slower, more brittle test suite that wasted system resources for no reason.

Again, I'm not maligning AI agents and asking you to stop using these tools. It's simply how AI tooling is currently trained and programmed to work (I wrote more about the cleanup side of this in Should You Fix AI-Generated Code or Rebuild It?). As developers and testers, we should still be the first line of defense when it comes to introducing changes into an application that have a negative effect on the health of the codebase.

What to Compare Between CI Test Runs

Even with all the new tests consistently being thrown our way by AI, we can and should take a bit of time to compare test runs to make sure our tests are in a healthy state. There's a lot that we can check between two commits or pull requests, but in my experience just a handful of comparisons will give you a clear picture of whether or not your test suite is declining in quality over time.

New and existing failures

We can start with the obvious by verifying any test cases that broke in the latest CI run when they were passing in the previous one. We all immediately check what failed, but many of us don't check if the specific test case failure is a brand-new one or one that was failing before. We need to know this to make the fix cheaper and easier, since we can isolate the change that triggered a new failure versus a failure that happened in earlier commits. In the AI era, if we can't pinpoint where a test failed, it can get buried in dozens of unrelated commits and be like finding a needle in a haystack.

Newly fixed tests

Checking for fixed test cases might seem like a waste of time. The test is green, after all, so isn't it a cause for celebration (or relief) instead of a cause for scrutiny? In the past, that might have been true. But nowadays, with AI agents dead-set on getting the build green, a fixed test doesn't always mean that the underlying problem was fixed. For instance, an AI agent might have tweaked a test case to pass by removing the failing assertion. The test passes now, but the bug that caused the assertion to fail still remains, and it's actually worse now because the test coverage is now gone.

Newly skipped tests

Along the same lines as checking for newly fixed tests, we should also keep a close eye on newly skipped tests. Personally, I advocate for never skipping tests unless there's a really good reason, since most of us tend to forget about why we skipped tests. There are some cases where it makes sense to skip a test, but AI agents are poor judges when it comes to determining whether a test case should be temporarily skipped. These systems often skip tests when they can't make a failing one pass, and they never go back to fix them unless explicitly told, so we should flag these cases if we see them.

Added and removed tests

Every automated test case in an application should serve a purpose, and removing one should have a reason behind it. As mentioned earlier in this article, AI loves to write unnecessary tests and is as quick to remove tests even if there's no justification for the deletion. We also can't rely only on the total test count, since an AI agent can delete 20 test cases and add 20 new ones in the same commit. We need to spend some time looking at new and removed test cases to make sure it was the right thing to do.

Tests that got slower

We often only check the total run time that it takes a CI service to complete, but that can hide a potential ticking time bomb lurking in the test suite. When left to write tests on its own and without explicit guidance, AI rarely pays attention to the test suite's performance. It leads to test runs gradually getting slower over time, and we won't notice it until it's too late. We should pay close attention to individual test cases that slowed down significantly between test runs alongside the total run time, since catching these early makes it cheaper to fix.

Flaky tests that fail every so often

We've all had to deal with flaky tests that pass 90% of the time, and seem to only fail when you're under a strict deadline. Unfortunately, we often don't have the information available to determine whether a test is flaky or not, since the failures happen sporadically and over a long period, and from a single test run we can't determine whether it was a one-time glitch, a failure due to a code change, or real flakiness. The best way to handle flakiness is to track pass and failure rates over time and address the ones that keep failing every so often for no reason.

How to Make These Comparisons Dead-Simple

Most of us don't have time to comb through CI logs to figure out what changed between two points of history in the codebase. Fortunately, you can use some functionality available on most test runners and CI services to make this easier for you and your team. Many test runners can output JUnit XML files with details about your test runs. Most CI services can save those files as a build artifact, and some can even process them into a human-readable format. Depending on the service you use, these can keep a historical record of your test suite over time to make it easier to know if something goes off the rails.

You can create a script that's triggered when the CI process is complete and pulls the XML files between two CI runs to compare them. The comparison can show which tests slowed down a lot, what's being skipped, and all the other checks mentioned in this article. You can also have your script post a summary of the comparison somewhere the team can see it, like on a Slack channel or a comment on the pull request that triggered the CI build. Having this information at hand makes it a lot easier to review AI-generated tests and know if the state of the application's testing is regressing.

There's a lot that goes into comparing test runs, from the different analyses needed to knowing what to compare against such as different feature branches or pull requests. This is one of the reasons why I built TestNod. Instead of building your own system, TestNod can keep track of all of your automated test runs by having your CI service upload a JUnit XML file and analyzing it over time to quickly alert your team to any potential issues automatically. It compares every test run and shows what changed between relevant commits, so you and your team know exactly what to look for.

No matter how you feel about using coding agents, the genie's out of the bottle. We'll continue to use AI to produce more code, more tests, and more pull requests, and we'll have challenges keeping up. With AI's goal of getting our tests to pass no matter what, we won't know how these systems reached that target. It's up to us to know if the test suite is green because the AI wrote proper tests or decided to skip or delete some because they were in the way. We also need to make sure the overall health of the test suite keeps up with the ramping up of new code introduced to our apps every single day.

Comparing each test run with the previous one is a good place to start reviewing these changes. If a test suddenly disappeared or is now taking twice as long to run than it did before, you'll know where to look first and what to ask the author (or the coding agent, as is the case nowadays). Some people might consider this unnecessary in the age of AI, but even if you're heavily using these tools, we still need to review what's happening under the hood. A test suite is only useful if your team knows what's still in it.

Test analytics for your CI builds

Your CI shows you one build at a time. TestNod keeps the results from all of them, so you can see which tests are flaky and when your test suite started getting slower.

Learn how TestNod works
Dennis Martinez

Rails, testing, and AI help for growing teams

I've been building Rails apps for over 20 years. Now I help small teams ship faster with test suites they can trust and AI workflows that fit how they already work.

  • Fractional Tech Lead
  • Testing Assessment
Learn more about my services

Learn practical end-to-end test automation with the End-to-End Testing with TestCafe book.

Learn more about the book