Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DevNexus 2020: Who Watches the Watchmen

DevNexus 2020: Who Watches the Watchmen

Tests are watching our code, helping it to not regress. But who’s watching the watchmen? Code coverage is often used to determine the quality of automated tests, trying to “test the tests”. Unfortunately all it does is ensure which lines of code have been executed by the tests, not if they are actually checking anything! Mutation testing is a way to really watch the watchmen. Matthew will give an introduction to mutation testing, why it’s better than traditional code coverage for measuring test quality, and demo examples using Pitest.

Demo Code: https://github.com/MatthewYKnowles/dev-nexus-2020

Matthew Y Knowles

February 21, 2020
Tweet

More Decks by Matthew Y Knowles

Other Decks in Programming

Transcript

  1. Matthew Knowles Software Engineer at Emmersion Learning www.EmmersionLearning.com @MatthewYKnowles [email protected]

    Who Watches the Watchmen Introducing a Better Metric of your Tests’ Quality
  2. Why Write Tests? • Verify functionality • Defend against unexpected

    change • Executable documentation of the code
  3. Adding Functionality to Legacy Code •Code Coverage •Limitations of Code

    Coverage •Mutation Testing https://github.com/MatthewYKnowles/Refactoring-Exercise-Rentals
  4. How would you mutate this code? 1. a < b

    2. a || b 3. a == b 4. if(a > b) {return a+b} 5. if(b > a) {a++}
  5. As hard-nosed as I am about TDD as a necessary

    discipline; if I saw a team using mutation testing to guarantee the semantic stability of a test-after suite; I would smile, and nod, and consider them to be highly professional. (I would also suggest that they work test-first in order to streamline their effort.) -Robert Martin (Uncle Bob)
  6. Questions? Further Reading: Filip van Laenen – Mutation Testing: Better

    Code by Making Bugs Martin Fowler – Refactoring @MatthewYKnowles