'Why does PIT fail to pick up my test class for my production class?

I am trying to make PIT run for a Spring/Maven-based Java project, but get strange results. My first runs show an overwhelming number of TIMED_OUTs for all sorts of mutations. The general recommendations in their FAQ, such as increasing the timeout settings, didn't yield any improvements.

So I picked out one sample to analyze what's happening: StringUtilities is a plain class with some static methods that perform simple string manipulations, such as trimming whitespace, etc. I entered <targetClasses><param>**.StringUtilities</param></targetClasses> to focus this class alone.

The surprising observation was that PIT's report listed tens of test classes in the "Tests examined" section that it ran. However, the most important one, StringUtiltiesTest, the unit test class that was specifically written for this live class, was not included. To verify, I entered it as <targetTests><param>**.StringUtilitiesTest</param></targetTests>, and indeed, PIT said it couldn't find any test and calculated 0% mutation coverage.

The obvious thing to do was checking the class path, but I cannot see anything strange about it. The preceeding Maven build picks the test class up alright. The project uses a standard main/test folder structure, and the class is located in the live package's test mirror.

One thing I did notice was that my test suite consists of a mix of JUnit 4 and JUnit 5 tests. The project is migrating to the newer version, but piece by piece, over a course of several weeks or months. StringUtilitiesTest is JUnit 5.

Does PIT have problems with such a version mixture? Are there other possible explanations why the test class isn't picked up?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source