Groovy Support
Requires pitest 1.22.0 or above. Feature is supplied by the arcmutate base plugin.
Background
By default pitest does not mutate bytecode compiled Groovy code as some language features require compiler generated constructs that do not map back to the source code. This results in confusing mutants that are hard to interpret, and junk mutations which cannot be reproduced by mistakes in the source code.
When the base plugin is installed and the feature +groovy is explicitly activated, Groovy classes will be mutated and junk mutations removed.
Groovy Mutators
A small number of Groovy specific mutators are provided. These enable arcmutate to mutate code constructs that appear similar to Java equivalents, but produce different bytecode. Where they do not result in junk mutations, the standard Java mutators will also be appalied.
If not already explicitly enabled, the Groovy mutators will be automatically enabled when their Java equivalents are enabled.
GROOVY_BOUNDARIES
Analagous to pitest’s CONDITIONAL_BOUNDARIES mutator, GROOVY_BOUNDARIES replaces the relational operators <, <=, >, >= with their boundary counterpart.
GROOVY_REMOVE_CONDITIONALS_FALSE
Analagous to pitest’s REMOVE_CONDITIONALS mutator GROOVY_REMOVE_CONDITIONALS_FALSE removes conditional statements, replacing them with false.
For example, the code
if (a == b) {
// do something
}
Would be mutated to
if (false) {
// do something
}
GROOVY_REMOVE_CONDITIONALS_FALSE
Analagous to pitest’s REMOVE_CONDITIONALS mutator GROOVY_REMOVE_CONDITIONALS_FALSE removes conditional statements, replacing them with false.
For example, the code
if (a == b) {
// do something
}
Would be mutated to
if (true) {
// do something
}
Installation
Before you can use the integration, you must first acquire a licence.
The licence file must be named arcmutate-licence.txt and placed at the root of the project. Alternatively dynamic licence retrieval can be used.
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.25.9</version>
<dependencies>
<dependency>
<groupId>com.arcmutate</groupId>
<artifactId>base</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
</plugin>
Or for gradle
dependencies {
pitest 'com.arcmutate:base:1.7.2'
}
The default version of pitest used by the gradle plugin is often very out of date. A modern version compatible with the Kotlin plugin can be configured with
pitest {
...
pitestVersion = '1.25.9'
...
}
See gradle-pitest-plugin documentation for more details.
Activation
Once the plugin is installed, Groovy support must be explicitly activated by supplying the feature string +groovy to the pitest configuration.