The fact that mutations can be benign really tempers the practical effectiveness. A normal test suite isn’t allowed to fail for a correct program. If it does, we say the test suite is defective. This is true even for test suites maintaining 100% branch coverage. If your program is correct, you can always add tests to get your test suite back to 100% branch coverage and make it green again.
Mutation testing doesn’t have this property. A mutation could be discovered that doesn’t break the tests (“survives”), while the program is still correct. My intuition is that this would be a large percentage of mutations on a brownfield codebase.
I think the adage of “no silver bullets” applies here. Different testing strategies will catch different kinds of failures, and that’s okay. There are bugs that fuzzers, end-to-end integration tests, property-based testing, or canaries, that no other type of testing can catch. It doesn’t necessarily mean one is better than the others or that they are the superior form of testing, but rather that incorporating those kinds of testing approaches gets us ever closer to the ever elusive state of “bug free” code. :)
if some_heuristic() {
use_index
} else {
full_scan
}
If you make some_heuristic very likely false, the tests will still pass (full_scan always work, but is usually slower).
So it will be easy to find mutants you can't kill (the ones that switch some_heuristic to false).
What I've been (trying to) do at work, where I have similar problems, is to have some auxiliary structure that explicitly encodes relevant decisions but isn't accessible outside of tests. And then a test asserts "we did X and not Y".
A few months ago I remember using mutation testing to see if a coding agent had just generated bogus tests. In the last month I routinely see these coding agents create mutations of their own volition, to double check themselves. I keep suspecting that much of the "intelligence" these things display is due to their owning companies' ability to roll out, test and evaluate software development practices at a massive scale.
I keep suspecting that much of the "intelligence" these things display is due to their owning companies' ability to roll out, test and evaluate software development practices at a massive scale.
Eh, maybe but then I'd also expect them follow a lot more of those practices by default. Instead people have to rely on using skills like superpowers to make them follow such practices in a relatively consistent way.
do they have to rely on them? I see an incredible amount of cargo-culting around skills, and since these coding agents don't use them deterministically, it's very hard to evaluate whether they actually make a meaningful difference in consistency.
If you've seen attempts to study their effect in a more methodical way, I'd be interested in seeing them if you have a link.
Cool idea! Definitely had never heard of this after fifteen years of writing software.
This is half-baked thought, but I feel like Lisp is an especially good language for this, since all you'd theoretically need is a macro you can wrap around an arbitrary test that would then trivially copy the module/namespace under test. Mutation is then a simple matter of walking the syntax tree and twiddling random knobs based on whatever the current node is. Has anyone tried this?
Not in Lisp, but I'm working on some mutation testing stuff at the moment that supports "mutant plugins" where you can provide functions that operates on an AST that matches certain shapes and rewrite them according to some criteria. An easy example would be shuffling / reparenthesizing operations that you would expect to associative & commutative.
matthiasportzel | 9 hours ago
The fact that mutations can be benign really tempers the practical effectiveness. A normal test suite isn’t allowed to fail for a correct program. If it does, we say the test suite is defective. This is true even for test suites maintaining 100% branch coverage. If your program is correct, you can always add tests to get your test suite back to 100% branch coverage and make it green again.
Mutation testing doesn’t have this property. A mutation could be discovered that doesn’t break the tests (“survives”), while the program is still correct. My intuition is that this would be a large percentage of mutations on a brownfield codebase.
wonk | 6 hours ago
I think the adage of “no silver bullets” applies here. Different testing strategies will catch different kinds of failures, and that’s okay. There are bugs that fuzzers, end-to-end integration tests, property-based testing, or canaries, that no other type of testing can catch. It doesn’t necessarily mean one is better than the others or that they are the superior form of testing, but rather that incorporating those kinds of testing approaches gets us ever closer to the ever elusive state of “bug free” code. :)
oliverpool | 15 hours ago
From an sqlite talk (probably https://www.youtube.com/watch?v=V_qzqY1bb7I) I remember that they noted one (big for them) blindspot:
If you make
some_heuristicvery likely false, the tests will still pass (full_scan always work, but is usually slower). So it will be easy to find mutants you can't kill (the ones that switch some_heuristic to false).quasi_qua_quasi | 8 hours ago
What I've been (trying to) do at work, where I have similar problems, is to have some auxiliary structure that explicitly encodes relevant decisions but isn't accessible outside of tests. And then a test asserts "we did X and not Y".
rs86 | 15 hours ago
I spent a whole year in masters working on elixir and mutation testing (and trying to parallelize it). God, it was really painful.
Now AI can fork a compiler to help with this in an afternoon….
Garbi | 13 hours ago
I always felt unit tests were far from sufficient. This makes perfect sense.
michiel | 6 hours ago
A few months ago I remember using mutation testing to see if a coding agent had just generated bogus tests. In the last month I routinely see these coding agents create mutations of their own volition, to double check themselves. I keep suspecting that much of the "intelligence" these things display is due to their owning companies' ability to roll out, test and evaluate software development practices at a massive scale.
creesch | 6 hours ago
Eh, maybe but then I'd also expect them follow a lot more of those practices by default. Instead people have to rely on using skills like superpowers to make them follow such practices in a relatively consistent way.
michiel | an hour ago
do they have to rely on them? I see an incredible amount of cargo-culting around skills, and since these coding agents don't use them deterministically, it's very hard to evaluate whether they actually make a meaningful difference in consistency.
If you've seen attempts to study their effect in a more methodical way, I'd be interested in seeing them if you have a link.
cmcaine | 20 minutes ago
The superpowers repo talks about testing that the skills are actually useful. Idk if their testing is any good
coby | 6 hours ago
Cool idea! Definitely had never heard of this after fifteen years of writing software.
This is half-baked thought, but I feel like Lisp is an especially good language for this, since all you'd theoretically need is a macro you can wrap around an arbitrary test that would then trivially copy the module/namespace under test. Mutation is then a simple matter of walking the syntax tree and twiddling random knobs based on whatever the current node is. Has anyone tried this?
iand675 | 4 hours ago
Not in Lisp, but I'm working on some mutation testing stuff at the moment that supports "mutant plugins" where you can provide functions that operates on an AST that matches certain shapes and rewrite them according to some criteria. An easy example would be shuffling / reparenthesizing operations that you would expect to associative & commutative.