4

我正在为我的项目使用 ptest-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>
4

2 回答 2

2

如果您希望 PIT 在突变测试不失败的任何时候失败,您只需将其设置mutationThreshold100意味着完全覆盖生成的所有突变。

于 2019-02-26T15:12:02.820 回答
1

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

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

有关的:

于 2021-05-09T13:24:24.420 回答