Running PITest on the ModulePath with the pitest-maven plugin

31 views
Skip to first unread message

Brendan D

unread,
May 24, 2022, 11:50:43 PMMay 24
to PIT Users

Hi there,

I've been trying to incorporate pitest into my maven build with the pitest-maven plugin. Unfortunately, I have been running into problems getting my tests passing.

I'm running on Java17 and my test suite normally runs through surefire on the modulepath (i.e. useModulePath=true). However, when attempting to run mutation against the suite, pit fails to calculate the line coverage as it encounters test failures. After some debugging, I discovered that this appears to be due to pit running the tests on the classpath rather than module path. The specific problem is that service loading doesn't work as the services are described in the module-info.java but not in META-INF/services. I was able to fix my tests by simply adding the services to META-INF/. Unfortunately, this would mean that I would need to maintain both the classpath and modulepath for my tests to run with surefire & pitest.

So I'm wondering if there is a way to have pitest-maven plugin run the tests using the modulepath? I did a bit of debugging and as far as I can tell it isn't possible (org.pitest.process.WrappingProcess seems to only set the CLASSPATH environment variable). Though, I’m hoping I'm just misunderstanding something.  

Thanks in advance for any help!

Brendan

Henry Coles

unread,
May 25, 2022, 10:35:24 AMMay 25
to pitu...@googlegroups.com
Hi Brendan,

Pitest doesn't currently support modulepath. The minimum java version it targets is 8, so modulepath support is a little awkward. It's probably possible to create a multi version build, but also probably not straightforward fun or easy.

If you can put together a minimal example project that demonstrates the issue you're hitting I'll see if some sort of workaround is possible.

Thanks

Henry

--
You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pitusers/1391cb86-da39-44bc-96da-9ec2bf0672c1n%40googlegroups.com.

Brendan D

unread,
Jun 7, 2022, 10:18:47 AMJun 7
to PIT Users
Thank you Henry for such a quick response.

My apologies for the delay. Unfortunately, I have been distracted by other issues over the past couple weeks which took my attention away from adding pitest to our build.

In any case, I've put together a small repo that outlines the problem. It's a bit convoluted but it shows the issue I have been having. See the README.md for more details about the repo and problem.

https://github.com/bdalcin/pit-example-module-path

I'm not sure if this is something that's easy to workaround without having the tests run on the module path for pit. The workaround of supporting both the META-INF/services in addition to the module-info.java isn't ideal but it has been working for me. Ideally pitest would (optionally) run the tests on the modulepath similar to surefire but I understand that's a tall order.

Thanks again,
Brendan
Reply all
Reply to author
Forward
0 new messages