pitest icon indicating copy to clipboard operation
pitest copied to clipboard

Tests without mutations fail (possibly related to Java 9 Modules)

Open turing85 opened this issue 2 years ago • 3 comments

Reproducer:

Noteworthy:

  • On all other modules, mutation testing works just fine.

  • The project uses almost no external dependencies (maven plugins, lombok, junit5, google truth and pitest, including the junit5 plugin for pitest)

  • The tests are all stateless, so no order problem

  • The only difference between the failing module and all other modules is that the failing modules takes advantage of Java modules by

    All tests in the aforementioned classes use the code related to the ServiceLoader. I suspect that the failing tests are related to this.

Logs of stdout and sterr are attached, run was done with --define verbose='true'.

turing85 avatar Mar 08 '23 01:03 turing85

Yes, the issue is the java 9 module system. Before 9, service loader looked for a properties file to identify implementations, after 9 it also looks at module-info.

Pitest doesn't currently support module path. At some point it will have to, but a significant proportion of its user base is still stuck on java 8 and maintaining backwards compatibilty would be complicated if the build relied on java 9 features.

As a workaround you could add the legacy property file entries and then I believe the tests should run green.

hcoles avatar Mar 08 '23 11:03 hcoles

Yes, the issue is the java 9 module system. Before 9, service loader looked for a properties file to identify implementations, after 9 it also looks at module-info.

Pitest doesn't currently support module path. At some point it will have to, but a significant proportion of its user base is still stuck on java 8 and maintaining backwards compatibilty would be complicated if the build relied on java 9 features.

Hm, I see. do we have this limitation documented somewhere?

As a workaround you could add the legacy property file entries and then I believe the tests should run green.

~~What exactly do you mean by this? Could you link to an example or a documentation page?~~ Found it (docs.oracle.com). And yes, you're right; this fixes the issue.

turing85 avatar Mar 08 '23 18:03 turing85

I just ran into this issue also. I have checked the documentation/FAQ especially the "My tests normally run green but PIT says the suite isn’t green" section. Finally, I have figured it out and applied the same workaround as proposed here. Until you fix it, I suppose the FAQ could be extended with a short description.

verhasi avatar Aug 27 '23 14:08 verhasi