Link Search Menu Expand Document

Git Integration Plugin

Plugin versions 0.1.0 and above require pitest 1.7.0 or above.

Plugin versions 0.0.1 to 0.0.13 require a pitest version between 1.6.7 and 1.6.9.

Maven Central

See maven setup for general instructions on how to configure pitest for a maven project.

Installation

Before you can use the integration, you must first acquire a licence. If you are working on an open source project you can get a free licence here. For commercial projects we are currently accepting requests for our beta programme.

The licence file must be named cdg-pitest-licence.txt and placed at the root of the project.

The plugin must be placed on the classpath of the pitest tool (not on the classpath of the project being mutated).

E.g for maven

<plugin>
  <groupId>org.pitest</groupId>
  <artifactId>pitest-maven</artifactId>
  <version>1.7.2</version>
    <dependencies>
      <dependency>
        <groupId>com.groupcdg</groupId>
        <artifactId>pitest-git-plugin</artifactId>
        <version>0.1.0</version>
      </dependency>
    </dependencies>
</plugin>

Or for gradle

dependencies {
  pitest 'com.groupcdg:pitest-git-plugin:version number'
}

See gradle-pitest-plugin documentation for more details.

Usage

Once installed the plugin must be activated as a pitest feature.

e.g to analyse only local uncommitted changes, assuming pitest has been bound to a phase called pitest

mvn -Dfeatures="+GIT" -Ppitest

To analyse changes compared to master

mvn -Dfeatures="+GIT(from[master])" -Ppitest

To analyse changes since a particular commit

mvn -Dfeatures="+GIT(from[c3174266f8e71abc8092f54398c93cd74c1b5f84])" -Ppitest

Files detected as being renamed will be ignored.

From and To

The commits to analyse are controlled by the from and two parameters.

These may be a git ref (e.g HEAD~1) or one the special values

  • -Local- - uncommitted changes (staged and unstaged)
  • -Empty- - a notional empty/root tree

If not supplied from and to default to HEAD and -Local-.

If HEAD does not exist, -Empty- will be used in its place.

Note that analysis is always performed with the current code (not the code as it existed at the point of the commit). The git range is used purely to select which classes to mutate, not to retrieve historic code.

Scope

By default only mutations on lines that have been modified will be analysed. The scope can be widened to consider all mutations in a modified class with the scope parameter.

It accepts two values

  • line (default)
  • class
mvn -Dfeatures="+GIT(scope[class])" -Ppitest

GitCi Output

The git plugin also enables a new output format gitci. This json output is used by the GitHub and Gitlab integrations to integrate pitest into pull request workflows.