AI-Written Tests Passed While Hiding a Penny-Off Bug in Every UK Invoice
A developer building a .NET invoicing library with AI coding assistant Claude discovered that 202 passing tests failed to catch a rounding error that would have misstated every UK invoice containing three items priced at £3.99. The bug stemmed from the library's rounding helper being tested in isolation, while the invoice calculator itself was never verified to actually call that helper. Manual mutation testing — deliberately breaking code to see which tests fail — exposed the gap, revealing that swapping the correct half-up rounding for .NET's default banker's rounding caused only five failures, none involving real invoice scenarios. Further probing found similar blind spots in discount calculations and a culture-formatting test that used round numbers, making it unable to detect the very formatting trap it was designed to catch. The episode illustrates a key risk with AI-generated test suites: when the same system writes both the code and its tests, passing results may only confirm internal consistency rather than correctness.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in