在 Maven 构建中跳过 运行 PITest
Skip running PITest in maven build
我正在尝试 运行 从命令行构建一个 Maven,并从 运行 宁任何突变中排除 PITest。目前报告失败,我们需要能够提供一个参数来忽略 运行 突变测试或忽略结果并继续构建
我有 运行 一些参数,例如 mvn package -Dpit.report=true
或mvn 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 并导致构建失败
没有跳过插件执行的本机方法,但至少有 2 个解决方法:
- 首先,添加一个 属性 来覆盖执行 phase:
定义一个属性 pitPhase
和默认值作为插件执行的默认阶段。
然后在插件配置中:
<execution>
<phase>${pitPhase}</phase>
...
</execution>
之后,当你想跳过执行时mvn -DskipPit=pitPhase package
- 另一种选择是添加 Maven profile 插件执行
在Maven中可以跳过Pitests的执行。
在你的pom.xml中:
- 在通用属性中设置:
<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.4.11 开始有选项 skipPitest
。看这里:https://github.com/hcoles/pitest/releases/tag/pitest-parent-1.4.11
所以你这样做:-DskipPitest
我正在尝试 运行 从命令行构建一个 Maven,并从 运行 宁任何突变中排除 PITest。目前报告失败,我们需要能够提供一个参数来忽略 运行 突变测试或忽略结果并继续构建
我有 运行 一些参数,例如 mvn package -Dpit.report=true
或mvn 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 并导致构建失败
没有跳过插件执行的本机方法,但至少有 2 个解决方法:
- 首先,添加一个 属性 来覆盖执行 phase:
定义一个属性 pitPhase
和默认值作为插件执行的默认阶段。
然后在插件配置中:
<execution>
<phase>${pitPhase}</phase>
...
</execution>
之后,当你想跳过执行时mvn -DskipPit=pitPhase package
- 另一种选择是添加 Maven profile 插件执行
在Maven中可以跳过Pitests的执行。
在你的pom.xml中:
- 在通用属性中设置:
<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.4.11 开始有选项 skipPitest
。看这里:https://github.com/hcoles/pitest/releases/tag/pitest-parent-1.4.11
所以你这样做:-DskipPitest