Urgent.News

What's breaking now, across hundreds of outlets.

Tech

100% Test Coverage and the App Still Had 2 Real Bugs

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…

In an article about test coverage, an AI agent was given a simple Express shopping cart API and tasked with writing tests. Astonishingly, the AI achieved 100% line coverage. However, this did not guarantee the absence of bugs. The API, comprised of 26 lines of code, allowed users to add items, calculate totals with coupons, and remove items. It had basic validation for item names, but no other checks.

The reporter then conducted "probing tests" to uncover hidden issues. First, they tested negative quantities, which the API accepted without error and responded with a 201 status code. They also tested sending non-numeric quantities, which resulted in the total returning as "NaN" (not a number). These two tests exposed real bugs in the system, despite the 100% line coverage. This demonstrates that coverage only measures which lines of code were executed, not their correctness.

To address these issues, the reporter added a single line of validation: if the quantity was not a finite number or was zero or less, a 400 error should be returned. Running the tests again, all nine tests passed, and the coverage remained at 100%. The reporter emphasized that coverage is simply a minimum check for code execution, not a measure of correct outputs. The tests that reveal real bugs focus on invalid inputs and unexpected behaviors.

In conclusion, the reporter advised that developers should write tests for the "what should never be allowed" scenarios at each endpoint before trusting the green checkmark indicating coverage. This precautionary measure ensures the app is less prone to breaking due to unnoticed bugs. The full experiment, including code and tests, can be found in a video available at https://youtu.be/JqhsD936gD0.

The report is part of a series called "Ship Stack," which presents real experiments on actual backends with concrete numbers and avoids vague explanations.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

US Prepares Defense, Regulatory, and Emergency Systems to Address Multi-Sector Cyberattack Risks

Executive Overview & Threat Landscape A black-level cyberattack is not a disruptive ransomware incident that locks enterprise file servers and recedes after a ransom payment.

  • US fortifying defense, regulatory, and emergency systems against multi-sector cyberattacks.
  • State-sponsored actors establish persistent footholds in critical infrastructure systems.
  • Connectivity of OT and ICS systems with enterprise networks amplifies cyberattack impacts.

Hitting Exact Target-KB Image Budgets and Routing HEIC/AVIF Locally in Web Workers

"Compress this image under 200 KB" is one of the most common form-upload requirements on the web—yet guesswork quality sliders almost always overshoot the byte budget or turn text unreadable.

  • Analyze ISO BMFF containers instead of relying on file extensions
  • Determine appropriate decoder by examining ftyp box in first 128 bytes
  • Achieve exact 200 KB target by bounded binary search and dimension adjustment

More from Monday, 30 November 2026 →