ISSUE #42 - December 17, 2017
You use tests to make your code better. You use mutation testing to make your tests better.
What is mutation testing: the basic idea is to inject bugs into your source code to establish whether your unit tests would find them, with the purpose of then adding the missing tests.
How to pick the right mutants to destroy in your code by adding only the useful missing tests:
Neither 100% coverage, nor 100% mutation coverage are a silver bullet against bugs. However, mutation testing clearly shows out pieces of code which need refactoring, and causes you to write more asserts and construct more detailed tests.
How mutation testing fits with agile process: use pairing, apply MT pragmatically to avoid shift from the useful mentality of “Did you think of this corner case?” to the much less useful “These 3% of expressions/mutants are not covered”, and use MT as a tool to promote refactoring in the Red-Green-Refactor cycle of TDD.
A neat story of debugging a Rails issue, found via mutation testing:
This is the list of current MT tools I’m aware of.
Mutation testing in Java with PIT:
Mutation testing in Python with Cosmic Ray or Mutmut:
Mutation testing in Ruby with Mutant or Mutest:
How Mutant gem works in Ruby, in much detail, for those interested in the technical underpinnings:
Worth learning: what happens when you press “play” on Netflix, from “what’s a CDN” to how machine learning fits in.
If you received this email directly then you’re already signed up, thanks! Else if this newsletter issue was forwarded to you and you’d like to get one weekly, then you can subscribe at http://testersdigest.mehras.net
If you come across content worth sharing, please send me a link at firstname.lastname@example.org