Mutation testing

What ?

Mutation testing is used to design new software tests and evaluate the quality of existing software tests.
Mutation testing involves modifying a program in small ways.

Code kata

Each mutated version is called a mutant and tests detect and reject mutants by causing the behavior of the original version to differ from the mutant.
This is called killing the mutant. Test suites are measured by the percentage of mutants that they kill. New tests can be designed to kill additional mutants. Mutants are based on well-defined mutation operators that either mimic typical programming errors (such as using the wrong operator or variable name) or force the creation of valuable tests (such as dividing each expression by zero).

Code kata

Mutant ?

Code kata

Why ?

How can measure the quality of our test do it ?

  • Use code coverage ?
  • Use your intuition ?

Think about it : “you could have a code base with 100% of code coverage without any assertions…” A good answer is mutation testing.

The purpose is to help the tester develop effective tests or locate weaknesses in the test data used for the program or in sections of the code that are seldom or never accessed during execution.

Code kata

How ?

  • Experiment pitest tool on your current code base
    • Inspect the tool
    • Check if it can help you in your day to day

Resources

Share this challenge