I Started AI Test Automation From Four Open Questions. Then My Tests Broke Under Me.
Month by month, from a page of unanswered questions to a test system I had to rewrite more than once, with the falls left in.
My first test commits on the AI team changed a single file. The next day, one commit carried 143 tests across six files.
They covered requests, error paths, the shape of responses, which configuration wins when two disagree, caching, and data that had to survive a round trip. I should back up, because that jump looks smoother than it was.
In January I’d written down four questions about one of the assistant’s tools: how it searched, how it picked among results, what it did with near matches, and whether it stored anything. Every box was still unchecked. Before that I’d spent a year and a half testing two mobile apps, mostly by hand, with some UI automation for critical flows and crash reports turned into test scenarios. The domain and its vocabulary were new. The first code I wrote in February wasn’t a test at all, just a small edit to one of the assistant’s instructions.
Then the tests started, and the concepts arrived together instead of one at a time. Some behavior finished asynchronously. Requests needed mocks so a test didn’t depend on a remote system. Fixtures had to be stable enough that two runs began from the same state. Responses needed shape checks. Similar cases needed parameters instead of copied blocks. A small local stand-in for a service made bigger flows possible without leaning on changing outside data. My first pull request on the AI side described itself as framework setup and unit tests, and not much more.
Here’s how the months went.
March was the first time I threw something away and rebuilt it. The example cases, which had lived as one file each, moved into catalogs with shared structure and metadata, and the older loader was deleted. That wasn’t a rename. It replaced one way of organizing examples with one that could grow.
April was about boundaries. A long, hand-built test setup got swapped for a short mock placed at the right edge of the computation, and a framework for testing the assistant’s instructions appeared. Then a batch of routing checks went red, and the useful discovery was that they weren’t one kind of red. Some expectations were stale, some hit limits in how the setup could walk a conversation step by step, and some were real gaps in behavior. Treating them all as defects would have meant changing the product until every test turned green, which would have fixed the wrong things.
In May the tests followed the product to the screen. Five commits in a day brought component, state, service, chart, login and shared-setup coverage to the frontend, exercising loading, streaming, history, themes, events, storage and errors.
June was a bigger fall. The product had moved while the tests stayed where they were. Interfaces had been renamed, clients replaced, event-loop behavior changed, and the context a request carries had been reshaped. I repaired dozens of test files, removed patches for code that no longer existed, deleted a test for a handler that was gone, and updated the async stand-ins until the suite ran again. That month also added a harness where a model judges the assistant’s answers.
July added scoring across several turns, captured fixtures, regression tests tied to specific defects, a QA guide, and the first offline evaluation check.
Before editing an assertion, ask whether the promise moved or the implementation broke it.
August was the third, and the one with the most repair work in it. Part of the month went to tests that measured more honestly: branches instead of lines, fuzzing, generated inputs, and mutation checks that change the code to see whether a test notices. Part went to cleaning up what that honesty exposed. Some tests depended on the order they ran in. Some assumed infrastructure that had changed. One was obsolete. Several were written ahead of the behavior they described. Later, an entire suite stopped collecting, which meant nothing in it could run at all. I fixed moved references, retargeted a couple of tests, and set one legacy suite aside on purpose until someone could rewrite or delete it properly.
September made checks strict enough to stop a change, with exact comparisons, loud failures, and fast checks running ahead of the long ones. When branches started red, I repaired the data and registrations behind them without lowering a threshold. October was mostly upkeep. Interfaces kept moving under existing tests, and I rewrote those tests to match with no change to production code. In November the suite stopped being only the examples I’d thought of. It started sweeping rules across every tool and generating its own inputs.
The recovery loop at the heart of all that is plain. First, find out whether the red case describes the current product. If the expectation is stale, rewrite it. If the behavior no longer exists by design, remove the obsolete test. If it points at a real gap that isn’t fixed yet, keep it visible without making every run unusable. Then rerun the focused checks and the broader suite.
The order matters. Before editing an assertion, ask whether the promise moved or the implementation broke it. Skip that, and a quick repair can preserve an old assumption and erase a useful warning.
This is not the same as making the output green by any available means. Deleting a useful assertion buys a calm result and a weaker system. A repair should leave the suite more honest about what’s supported, what’s broken, and what has changed.
Some design choices only made sense after I’d been burned by them. A small stand-in is easier to trust than a large imitation, because the more behavior a fake environment recreates, the more places it can drift. A focused fake gives the case the response it needs and leaves the decision under test in real code. Parameterized cases cut repetition but let one shared mistake travel farther, so each parameter needs a reason to be there. Catalogs saved duplication, but an inherited assumption could touch many cases at once, so each case had to keep enough local meaning that a failure pointed at a user behavior and not just a catalog row.
The recovery I’d point to first is the known gap. Defects I found got pinned as strict expected failures: the test describes the right behavior, runs red on purpose, and fails the build if it ever passes unexpectedly. Later, when the underlying behavior was fixed, the markers came off, and the same tests stayed as ordinary regression checks. The test I’d written to document a gap turned into the test that proved the fix.
That left a question I couldn’t have asked in January. If a check is green, how do you know it could have been red?