我正在为我的项目使用最简单的maven插件,如果有任何变异失败,我希望maven构建失败。
但我看不到允许我这样做的配置选项。我可以看到mutationThreshold和coverageThreshold,但它们都不起作用。
理想情况下,我希望使用PIT来确保我编写的测试不会失败任何突变,而不是试图满足全面的覆盖指标。
有什么办法吗?
当前maven配置:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.4.0</version>
<configuration>
<mutationThreshold>100</mutationThreshold>
</configuration>
</plugin>
如果您想让PIT在突变测试未失败的任何时候失败,您只需将突变阈值设置为100,这意味着所有生成的突变都能完全覆盖。
pitest的最新版本(我认为是1.6.2)包括一个测试强度阈值,它只考虑覆盖的代码(即,如果构建因未覆盖的行而失败,则需要添加额外的覆盖限制)。
/**
* Test strength score threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "testStrengthThreshold")
private int testStrengthThreshold;
相关: