Recently , the project has been migrated from Java8 to Java17 . The mutation test coverage is also checked for the project and before migration there was no known issues during the command run of mvn clean install org.pitest:pitest-maven:mutationCoverage
After migration , the issue is reported as Execution default-cli of goal org.pitest:pitest-maven:1.7.6:mutationCoverage failed: 6 tests did no t pass without mutation when calculating line coverage. Mutation testing requires a green suite.
The pom.xml file has
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.6.2</version>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>0.12</version>
</dependency>
</dependencies>
</plugin>
Note: There are few test cases contain Whitebox.invokeMethod to invoke the private method. There are no issues during the run of the test cases - mvn clean install. The actual problem occurred during the run of mutation test coverage with the command - mvn clean install org.pitest:pitest-maven:mutationCoverage
I tried to include the option --add-opens java.base/jdk.internal.misc=ALL-UNNAMED in pom.xml file but of no use.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
I tried to change the version of pitest-maven as 1.7.3 from 1.6.2 and pitest-junit5-plugin as 0.15 from 0.12. This is also not useful.
Any idea or suggestion to overcome the pitest-maven in Java17 with WhiteBox.invokeMethod in test cases.
The correct version of pitest-junit5-plugin was helpful to get rid of the error.
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.11.0</version>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>1.1.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
Along with the junit pitest-junit5-plugin addition , adding --add-opens is also required ,
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.11.0</version>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
</argLine>
</configuration>
</plugin>