【发布时间】:2018-08-16 20:03:03
【问题描述】:
这似乎是一个很常见的问题,我个人至少偶然发现了几次。
一些主要原因是:
- 在运行 ptest 之前忘记运行测试(从而创建测试类):Pitest can't detect class of test、PITest cannot find tests。
- 未配置
targetTests: pitest doesn't find tests -
assert关键字使用不当:pitest not able to locate junit test
但是,今天我偶然发现了一个新的 0 测试案例,我很难解决。让我们考虑这个项目:https://github.com/bonnyfone/vectalign.
这是一个小项目,只包含一个测试类:
src
|
+- main
| |
| ...
|
+- test
|
+- java
|
+- VectAlignTest.java
我在pom.xml 中添加了pitest:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.2</version>
</plugin>
我运行命令mvn clean test org.pitest:pitest-maven:mutationCoverage。
虽然测试运行良好,但由于某种原因,pitest 无法找到它们:
12:23:16 PM PIT >> INFO : MINION : 12:23:16 PM PIT >> INFO : Found 0 tests
...
================================================================================
- Statistics
================================================================================
>> Generated 910 mutations Killed 0 (0%)
>> Ran 0 tests (0 tests per mutation)
您可以在此处找到完整的pom.xml:https://pastebin.com/F28ZpcMk
这是mvn clean test org.pitest:pitest-maven:mutationCoverage的完整输出:https://pastebin.com/tWHgq43a
现在我的问题是,在这种特殊情况下出了什么问题? Pitest如何确定哪些是测试类?
您的帮助将不胜感激:)
【问题讨论】: