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
The obligatory speed test thread :smiley: Check here: https://www.speedtest.net When complete, click on the share link and copy and pas...
New
justinjunodev
Figured this would be a cool topic and maybe provide some inspiration for those who are just starting to work from home. Feel free to sha...
New
AstonJ
If you had the ear of a language creator, what would you say - what could they do to make a language that you would use? :upside_down_face:
New
chasekaylee
Hi everyone! I have been in the professional industry for ~2 years now coming from a boot camp. I started a base foundation by programmin...
New
AstonJ
If you could work on any project, what would it be? :upside_down_face:
New
Exadra37
Have you ever wanted to build something but you had no idea what to do? Just as authors sometimes have “writers block” it’s also true for...
New
AstonJ
Just been adding some more portals, currently have the following languages: Apache Groovy C C# C++ Clojure CoffeeScript Crystal ...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
dwaynebradley
For those that are interested, Snyk (developer security tool) announced support for Elixir earlier this week: Just thought I’d pass it...
New
Exadra37
My brother got a VPS on https://contabo.com hosting provider, but I was not aware of them, and when my brother told me the price and spec...
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
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
AstonJ
Or looking forward to? :nerd_face:
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
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
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New