home · quickstart · faq · downloads · news · links · email · rss

PIT Mutation Testing

PIT is a fast bytecode based mutation testing system for Java that makes it possible to test the effectiveness of your unit tests.

You can think of mutation testing as either as an automated test of your tests, or as a much more in depth form of code coverage.

Unlike traditional line and branch coverage tools PIT does not just confirm that your tests execute your code, it confirms that your tests are actually able to detect faults in it.

How it works in 51 words

Mutation testing is conceptually quite simple. Faults (or mutations) are automatically seeded into your code, then your tests are run. If your tests fail then the mutation is killed, if your tests pass then the mutation lived.

The quality of your tests can be gauged from the percentage of mutations killed.

What?

To put it another way - PIT runs your unit tests against automatically modified versions of your application code. When the application code changes, it should produce different results and cause the unit tests to fail. If a unit test does not fail in this situation, it may indicate an issue with the test suite. 1

Output

PIT produces easy to read HTML reports combining line coverage and mutation coverage information.

Example snippet taken from coverage report of Wicket Core

Light green shows line coverage, dark green shows mutation coverage.

Light pink show lack of line coverage, dark pink shows lack of mutation coverage.


  1. Thanks to James Watson at the serverside.com for this alternative explaination