It seems that this is a quite common issue and I personally stumbled on it at least a couple of times.
Some of the main causes being:
- Forgetting to run the test (and thus create the test classes) before running pitest: Pitest can't detect class of test, PITest cannot find tests.
- Miss-configured
targetTests
: pitest doesn't find tests - Improper use of the
assert
keyword: pitest not able to locate junit test
However, today I stumbled upon a new case of 0 tests found, which I struggle to solve. Let us consider this project: https://github.com/bonnyfone/vectalign.
It is a small project and includes one only test class:
src
|
+- main
| |
| ...
|
+- test
|
+- java
|
+- VectAlignTest.java
I added pitest to the pom.xml
:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.2</version>
</plugin>
I run the command mvn clean test org.pitest:pitest-maven:mutationCoverage
.
While the test run just fine, for some reason pitest cannot locate them:
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)
You can find the complete pom.xml
here: https://pastebin.com/F28ZpcMk
And here is the complete output for mvn clean test org.pitest:pitest-maven:mutationCoverage
: https://pastebin.com/tWHgq43a
Now my question is, what is going wrong in this particular case? How does pitest determine which are the test classes?
Your help would be much appreciated :)