logoalt Hacker News

hungryhobbit • today at 5:35 PM • 1 reply • view on HN

The irony here is that AI makes this easier ... while also making it less valuable.

What I mean is, except for literal typos, bugs aren't generally caused by one character being off. They're caused by (say) not remembering function X will do Y under condition Z.

So, it's a proxy: you find tests that fail to catch typos as a proxy for catching tests that might miss real issues.

But how good of a proxy is it? Will finding out if a bunch of my tests miss == becoming != tell me if my tests will catch me forgetting to pass that critical foo argument to my doBar? ¯\_(ツ)_/¯

The one thing we know mutation testing is good for is catching typos, and with AI writing all my code, typos are the last thing I worry about.


Replies

kragen • today at 7:07 PM

Mutation testing is very good at telling you which parts of your code your regression tests aren't testing at all. If you change doBar to always return 53, or set this.bar to 53, or whatever it does normally, but wrong, any tests depend on doBar to do something sensible will start failing. If there aren't any such tests, they won't catch you forgetting to pass that critical foo argument. That's a weak guarantee — what you'd like to know is the converse — but it still seems worthwhile to me.

(I'm sorry I sound like Claude; I've been dealing with Claude all day.)

Sometimes mutation testing also tells you when you have useless code (because it's impossible to catch a particular mutant in tests). It can also tell you when you have useless tests.

As with other coverage testing techniques, often the most valuable thing about it is that it tells you your test suite is poorly thought out in a particular area. The right response is not just to add a test that covers the particular mutant that got through, but to think through that part of the test suite again and add possibly several tests to it — possibly including tests that will fail currently, because they're testing cases that the implementation forgot about too.