1

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.

6
  • 1
    You have to upgrade pitest to the most recent versions (1.11.0) and the pitest-junit5-plugin to 1.1.2 search.maven.org/search?q=org.pitest , search.maven.org/artifact/org.pitest/pitest-junit5-plugin/1.1.2/… furthermore running the test it's sufficient to use mvn clean verify instead of mvn clean install Commented Feb 4, 2023 at 7:09
  • After setting to the most recent versions also, the same issue is reported during pitest coverage - mvn clean install org.pitest:pitest-maven:mutationCoverage Commented Feb 4, 2023 at 7:15
  • 2
    If you enable pitest's verbose logging (mvn -Dverbose=true or update the pitest config) it will write the names of the failing tests to the log. The output will also contain the details of the error encountered while running the test. Also, be aware that the pitest-junit5-plugin version to use depends on both the version of pitest you are using and the version of junit 5 as per the plugin's readme github.com/pitest/pitest-junit5-plugin. Commented Feb 4, 2023 at 9:55
  • 1
    It would also being helpful to know what versions of surefire plugin you are using and as already mentioned by @henry the version of junit-jupiter also the whole pom file would be helpful here... and do all the test run without any issue without pitest? Commented Feb 4, 2023 at 11:21
  • Thanks a lot Henry and Khmarbaise. 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> Commented Feb 6, 2023 at 3:42

1 Answer 1

0

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>
Sign up to request clarification or add additional context in comments.

3 Comments

we are getting following error Kill ratio is NaN% (0 0) before we used java11 it worked but after migration to Java 17 we are getting the above issue following version i used Jenkins Plugin - pitmutation:1.0-18 pitest-maven: 1.11.0 pitest-junit5-plugin: 1.1.2
Did you check 1. The correct pitest-junit5-plugin version is used? 2. Added this line <argLine> --add-opens java.base/java.lang=ALL-UNNAMED </argLine> ?
i have used the same version as you mentioned and used the same plugin as above here is the complete issue stackoverflow.com/questions/76703339/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.