Link Search Menu Expand Document

GitLab Integration

Projects with the git plugin configured can be setup to run pitest against merge requests, mutating only the lines of code affected by the changes. This is a very effective way to use mutation testing. Analysis usually takes only seconds, no matter how large the codebase.

The results are displayed directly in the MR. A comment is created each time changes are pushed, showing a summary of the mutation testing results.

example GitLab comment

An discussion is also creating for each line of code with surviving mutants, this is visible in the diff view.

example GitLab discussion

Plugins are provided for maven and gradle

Licence

Before you can use the integration, you must first acquire a licence.

Once you have the licence you should place the file it in the root of your git repo. Do not change the name from arcmutate-licence.txt

Maven Configuration

Gitlab integration is provided by the pitest-gitlab-maven-plugin

Before configuring the maven plugin, first configure the pitest-git plugin.

The CDG pitest-git plugin and pitest-gitlab-maven-plugin are always released together, and their version numbers should be kept in sync. This can be achieved by creating a property.

<properties>
  <cdg.pitest.version>2.0.0</cdg.pitest.version>
</properties>

The pitest-gitlab-maven-plugin can then be added to the pluginManagement section of your pom (or plugins section if it is a single module project).

<plugin>
    <groupId>com.arcmutate</groupId>
    <artifactId>pitest-gitlab-maven-plugin</artifactId>
    <version>${cdg.pitest.version}</version>
</plugin>

When running in GitLab CI configuration is largely automatic. Only the repoToken token must be explicitly supplied.

Generate a Personal or Organisation Access Token with api level access to the repositories you wish to mutate.

This can then be set as a CI variable. If the environment variable is named repoToken it will be automatically detected, if a different name is chosen it can be passed to maven on the command line.

By default GitLab only makes CI variables available on protected branches. This option must be unticked for the variable, or all PR branches configured as protected.

Additional parameters must be explicitly set on other CI systems.

See here for a working example using the plugin with GitLab CI.

Gradle Configuration

Setup with gradle is similar to maven. See GitLab gradle plugin for details.

This can be seen in action in the example gradle project