Everyone says check your test coverage. So I gave an AI agent a messy shopping cart API in Express, asked it to write tests, and measured the coverage. It hit 100%. The app still had two real bugs. Here is what happened.
The app
A small Express cart API, 26 lines. You can add items, get a total with two coupon codes, and remove items. It looks fine at a glance. Nothing is validated except the item name.
The happy paths
The agent wrote tests for the happy paths: adding an item, the total, the 10% coupon, the half-price coupon that only works over $20, and deleting. All seven tests pass. Line coverage: 100%.
If you stopped here, you would ship it.
The probing tests
Then I added two tests that ask what should never be allowed.
- Negative quantity. The server accepts it and answers 201.
- Text quantity. Send quantity "ABC" and the total comes back as NaN.
Both are real bugs. 100% line coverage did not catch either one, because coverage only tells you which lines ran, not whether the answers were right.
The fix
One line of validation: if the quantity is not a finite number, or is zero or less, return a 400. Run the tests again: all nine pass. Coverage is still 100%, exactly where it started. The metric never moved; the app is meaningfully less broken.
The takeaway
Coverage is a floor check, not a correctness check. The tests that find real bugs are the ones that ask what should never be allowed: negative numbers, wrong types, empty strings, absurd sizes. Write a few of those for every endpoint before you trust the green checkmark.
The full run, with the code and every test on screen, is in the video:
We are building Ship Stack: real experiments on real backends, with the actual numbers, no hand-waving. More of these are on the channel.
Top comments (0)