看起来这是一个非常普遍的问题,我个人至少遇到过几次。
一些主要原因包括:
- 在运行 pitest 之前忘记运行测试(从而创建测试类):Pitest can't detect class of test,PITest cannot find tests。
- 目标测试配置错误: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
我已经将pitest添加到pom.xml中:
<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 如何确定哪些是测试类?
非常感谢您的帮助 :)