Logo

dev-resources.site

for different kinds of informations.

Mutation testing in 1000 characters

Published at
12/7/2018
Categories
tests
craftsmanship
mutation
Author
schreiber_chris
Categories
3 categories in total
tests
open
craftsmanship
open
mutation
open
Author
15 person written this
schreiber_chris
open
Mutation testing in 1000 characters

Code coverage is an common metric to measure code quality but it doesn't guarantee that tests are really testing the expected behavior.

Mutation testing can be described as tests of tests. It consists of introducing mutations to your codebase and checking if at least one test fails for each mutation (we say that mutation is killed in this case, otherwise it lived):

  • inversion of conditions
  • change boundary conditions (< becomes <=)
  • change incrementation of counters
  • change mathematical operators
  • return null instead of returned value
  • don't call void methoids, constructors...
  • many other type of transformations

If a mutation is killed, that means that your tests are covering some edge cases, giving you more confidence about the quality of your tests.

Mutation testing can be an heavy process, so it doesn't need to be executed as often as unit tests, but it can be a step in your release process.

Java projects can use Pitest library.

Featured ones: