在Maven构建中跳过运行PITest

3
我正在尝试从命令行运行maven构建,并排除PITest的任何变异。目前报告失败,我们需要能够提供一个参数来忽略运行变异测试或忽略结果并继续构建。
我已经使用一些参数运行,例如mvn package -Dpit.report=truemvn package -Dmaven.report.skip=true
这是我的pom中的PITest设置。
<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>

问题在于仍在运行PITest并导致构建失败。
3个回答

3

1

在Maven中可以跳过Pitests的执行。

在您的pom.xml文件中:

  1. 设置一般属性:

<properties> 
       <pitest.execution.skip>true</pitest.execution.skip> 
</properties>

在插件中设置:
 <plugin>
         <groupId>org.pitest</groupId>
         <artifactId>pitest-maven</artifactId>
         <version>Your_Version</version>
         <configuration>
            <skip>${pitest.execution.skip}</skip>
         </configuration>
 </plugin>

1

没有本地方法可以跳过插件执行,但至少有两种解决方法:

  • 首先,是添加一个属性来覆盖执行阶段

定义一个名为pitPhase的属性,其默认值为插件执行的默认阶段。

然后在插件配置中:

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

之后,如果你想跳过执行,可以使用mvn -DskipPit=pitPhase package

  • 另一种选择是添加一个Maven profile与插件执行配合使用

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接