davearonson

davearonson

Mutation Testing

Continuing the discussion from What dev-related stuff have you been up to?:

“Perfect” would take further definition, but to “check” or “improve”, yes, that’s one of the main benefits. The other main one is to find “dead” code, that’s unreachable or redundant or otherwise not doing anything important enough that you’ve made a test depend on it.

Not quite, but thinking in “size” terms like that is one of the metaphors used by Markus Schirp, the author of Mutant. He likens it to trying to ensure that the area covered by the unit tests is the same as the area covered by your code. Where the tests cover but the code doesn’t, you have a failing test, which of course shouldn’t be happening, and is discovered by the usual means of just running the tests. The more interesting case is where the code covers but the tests don’t, which means you have untested code, that should be either tested or removed. So, the effect on your test suite is generally not to shrink it but to expand it.

Note though that code being “tested” doesn’t mean it needs its own explicit tests, just that it needs to make a difference to the success or failure of at least one test. So frex you don’t need to have tests explicitly for every little trivial function like a getter or setter – but if you mutate a getter or setter, it darn well better break some test, generally one on more complex code that depends on that getter or setter.

Yes, there are some similarities. I’ve made a similar comparison in some of my talks on it, specifically referring to “fuzzing”, a form of property testing designed to find security holes. You can think of mutation testing like fuzzing the code rather than the data. However, another big difference is that mutation testing (generally) isn’t random. A mutation testing tool will generally apply all the mutations it knows how to do. (Except that some of the smarter ones will look at results of certain ones and know it doesn’t need to apply certain other ones, as it will be able to predict the results.)

It might help to watch one or two of my talks on it. The playlist is at https://www.youtube.com/playlist?list=PLMrm16n64Bub8urB-bsyMyHiNPMLG7FAS and they’re in reverse chronological order. Other than the earliest one, which I recommend you ignore, they range from a 22 minute overview, to a 52 minute deeper dive.

Where Next?

Popular General Dev topics Top

AstonJ
Which apps do you think are killing it right now? Either from a technical perspective or ones that you like personally or feel have been...
New
chasekaylee
I’ve been using the classic notebook to-do list, but I’m curious to hear what awesome tools are out there that I am not aware of. I’m alw...
New
mjk
TL;DR: words that incorporate negation are acceptable, eg. independent, asymmetric, nondeterministic. An example in the book is to renam...
New
AstonJ
Do you think it’s worth worrying about? Do you think it’s going to be an even bigger issue in future? If so what can the teams of smaller...
New
OvermindDL1
What shell(s) do you use, why do you use them, and how do you have them configured? Note, this is about shell’s, not terminals, terminal...
New
dwaynebradley
In their weekly newsletter, Jared Santo from the Changelog shared this blog post by Mark Ericksen over at fly.io: What is really inter...
New
GermaVinsmoke
Do you like to help others on stackoverflow in your free time? And what’s your reputation on Stackoverflow? :smirk::joy::rofl:
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
AstonJ
Do we have any digital nomads here? Anyone fancy it? If so, which countries would you consider? I’ve been toying with the idea for a wh...
New
DevotionGeo
For me it’s six to seven steps above complete dark, on MacBook Air M1.
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
PragmaticBookshelf
Explore the power of Ash Framework by modeling and building the domain for a real-world web application. Rebecca Le @sevenseacat and ...
New