【问题标题】:PIT Mutation testing on apache commons math shows line coverage and mutation coverage as 0%apache commons math 上的 PIT Mutation 测试显示线路覆盖率和突变覆盖率为 0%
【发布时间】:2014-12-24 15:31:33
【问题描述】:

我正在尝试将 PIT Mutation 测试与 maven 一起用于 apache 常见数学测试。

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>0.29</version>
    <configuration>
        <targetClasses>
            <param>org.*</param>
        </targetClasses>
        <targetTests>
            <param>org.*</param>
        </targetTests>
    </configuration>
</plugin>

我将此添加到我的 pom.xmlmvn org.pitest:pitest-maven:mutationCoverage。我可以运行它,但索引文件显示 Line Coverage 和 Mutation Coverage 为 0%。我想我没有正确给出参数。此外,我需要改变 apache-common-math 的一项测试,例如LU分解。

【问题讨论】:

  • 0.29 已经很老了——修复了一些错误。使用 1.1.0。你在输出中有任何错误吗?您可以与 Gist 或 Pastebin 共享输出。
  • pastebin.com/3pMyViti。我尝试过更突然结束的 1.1.0 版本。这是版本 1.1.0 pastebin.com/wdXmig1h 的错误。
  • org.* 范围很广 - PIT 的类也匹配 (org.pitest)。正如我在回答中建议的那样,您可以省略这两个参数进行基本分析或将其定义为org.apache.commons.math3.*
  • “变异一个测试”是什么意思?如果您的意思是您只想为特定类创建突变,请将 targetClasses 设置为 org.apache.commons.math3.linear.LUDecomposition 并将 targetTests 设置为 org.apache.commons。

标签: java maven maven-plugin mutation-testing pitest


【解决方案1】:

在运行突变测试分析之前,运行mvn test 编译主类和测试类(顺便验证所有测试是否通过,这可能会影响 PIT 结果)。

mvn clean 之后或在新克隆的存储库上,PIT 没有任何要变异的类,您可以获得提及的消息。

默认情况下,Maven 的 PIT 插件将 groupId 作为基础包,因此对于 commons-math,完全省略配置部分是可以的。还将 PIT 版本更新到 1.1.0(或最新的可用版本),以免遇到已修复的错误。

【讨论】:

  • pastebin.com/0N6NXe70 这是我在执行 mvn test 后遇到的错误,然后运行突变分析。如何防止内存堆空间错误。
  • 使用jvmArgs(PIT配置)参数增加-Xmx。参考that
猜你喜欢
  • 2015-10-06
  • 2017-05-31
  • 1970-01-01
  • 2022-07-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-11
  • 1970-01-01
  • 2012-01-18
相关资源
最近更新 更多