Sonar Pitest Plugin
Description / Features
Pitest is a mutation testing tool for java. You can check out the official pitest web site for more details on mutation testing and pitest.
Long story short, mutation testing is a very smart way to check the relevance of unit tests. The main idea is to alter the tested code and check that at least one unit test fails. An alteration of the code is called a "mutant". A mutant has "survived" the tests if there is no test failure.
The goal of this plugin is to bring pitest results to sonar. Right now the integration of these result is quite simple, "survived mutants" on code covered by tests are seen as sonar violations.
Note : even if pitest detects "survived mutants" on uncovered lines of code, these mutants are simply ignored by the plugin.
Usage & Installation
Right now the plugin does not execute pitest. Pitest needs to be run prior to any sonar analysis using either maven or the command line... You can check out the quickstart section of the official pitest web site for detailed instructions.
Pitest needs to be configured in order to generate XML reports. The default behavior is to generate HTML reports. Below a simple configuration example for maven :
inScopeClasses and targetClasses parameters indicated the classes of the system under test where mutations can be performed. In the example from the sonar gallio plugin for C#, all the classes from the org.s.p.c.gallio package and sub packages may be altered.
Once configured in the maven pom file, you need to run pitest using the following command "mvn org.pitest:pitest-maven:mutationCoverage".
All the configuration options are clearly explained in the official pitest documentation.