RyderSchoon
RyderSchoon

Reputation: 33

Skip running PITest in maven build

I'm trying to run a maven build from command line and exclude PITest from running any mutations. Currently the reports are failing and we need to be able to give a parameter to ignore running the mutation tests or ignore the results and continue the build

I've running with some parameters like mvn package -Dpit.report=true

or mvn package -Dmaven.report.skip=true

This is the PITest setup in my pom

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.1.10</version>
    <configuration>
        <timestampedReports>false</timestampedReports>
        <mutationThreshold>95</mutationThreshold>
    </configuration>
    <executions>
        <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>mutationCoverage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The problem is that is is still running PITest and causing the build to fail

Upvotes: 3

Views: 4633

Answers (3)

john16384
john16384

Reputation: 8054

Since 1.4.11 there is the option skipPitest. See here: https://github.com/hcoles/pitest/releases/tag/pitest-parent-1.4.11

So you do: -DskipPitest

Upvotes: 4

SebastianJ
SebastianJ

Reputation: 95

The execution of Pitests can be skipped in Maven.

In your pom.xml:

  1. Set in general properties:

<properties> 
       <pitest.execution.skip>true</pitest.execution.skip> 
</properties>
  1. Set in the plugin:
 <plugin>
         <groupId>org.pitest</groupId>
         <artifactId>pitest-maven</artifactId>
         <version>Your_Version</version>
         <configuration>
            <skip>${pitest.execution.skip}</skip>
         </configuration>
 </plugin>

Upvotes: 1

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10074

There is no native way of skipping a plugin execution, but there are least 2 workarounds:

  • First, is adding a property to override execution phase:

Define a property pitPhase with default value as the default phase of plugin execution.

Then in plugin configuration:

<execution>
   <phase>${pitPhase}</phase>
   ...
</execution>

After that, when you want to skip execution mvn -DskipPit=pitPhase package

  • The other alternative is to add a Maven profile with the plugin execution

Upvotes: 1

Related Questions