Mutation testing is an advanced testing technique that evaluates the effectiveness of your test suite by making small changes (mutations) to your source code and checking if your tests can detect these changes. It goes beyond traditional code coverage by measuring not just whether your code is executed by tests, but whether your tests can actually detect bugs.
The process of mutation testing follows these steps:
The primary metric in mutation testing is the mutation score:
Mutation Score = (Number of Killed Mutants / Total Number of Mutants) × 100%
A higher mutation score indicates a more effective test suite that's better at detecting potential bugs.
Mutation testing tools apply various types of mutations, including:
While more resource-intensive than basic code coverage, mutation testing offers significant benefits:
Some widely used mutation testing tools include:
Mutation testing is a powerful complement to traditional code coverage metrics, helping teams build more robust and reliable software.
PR comments, status checks, line annotations, and trends without code access. Free for public repos; per-repo pricing for private repos.