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

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
What do you think needs fixing in the digital / computer science sphere?
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
finner
When you are under pressure to deliver you ideally want your Pull Request to be reviewed, approved and merged as quick as possible. So do...
New
New
AstonJ
Just listened to @rvirding’s interview here and he mentions #lua (and Luerl) - just wondered if anyone’s used Lua and what you think of it?
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1147 28379 760
New
jaeyson
Hi!, hope everyone’s ok. Sorry if this question is ambiguous (i’ll remove this if i break some rules here). This is more like a self-ques...
New
DevotionGeo
I am planning to refresh my Ruby knowledge in a month or two, after using other technologies more frequently for a few years. Luckily I w...
New
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
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
AstonJ
Or looking forward to? :nerd_face:
485 12328 258
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
PragmaticBookshelf
Create efficient, elegant software tests in pytest, Python's most powerful testing framework. Brian Okken @brianokken Edited by Kat...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
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
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
A concise guide to MySQL 9 database administration, covering fundamental concepts, techniques, and best practices. Neil Smyth MySQL...
New