当任何 PIT 突变失败时,maven 构建可能会失败,而不是突变覆盖?

Possible to fail maven build when any PIT mutation fails, rather than mutation coverage?

我正在为我的项目使用 pitest-maven 插件,如果有任何突变失败,我希望 maven 构建失败。

但是我看不到允许我这样做的配置选项。我可以看到 mutationThresholdcoverageThreshold,但这些都不起作用。

理想情况下,我想使用 PIT 来确保我编写的测试不会因任何突变而失败,而不是尝试满足全面覆盖率指标。

有什么办法吗?

当前的 Maven 配置:

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.4.0</version>
    <configuration>
        <mutationThreshold>100</mutationThreshold>
    </configuration>
</plugin>

如果您希望 PIT 在变异测试未失败的任何时候失败,您只需将 mutationThreshold 设置为 100,这意味着完全覆盖所有生成的变异。

pitest 的最新版本(我认为是 1.6.2+)包括一个测试强度阈值,它只考虑被覆盖的代码(即,如果构建因未被覆盖而失败,您需要添加额外的覆盖限制行)。

   /**
   * Test strength score threshold at which to fail build
   */
  @Parameter(defaultValue = "0", property = "testStrengthThreshold")
  private int                         testStrengthThreshold;

相关: