3

i see the following stacktrace when running the pitest gradle task in my project after adding all the required configurations in build.gradle. Can you please help me on this ? I'm using 1.5.1 version of the plugin.

The changes have been done in build.gradle as per the instructions in https://github.com/szpak/gradle-pitest-plugin

7:00:32 PM PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
    7:00:33 PM PIT >> INFO : Sending 46 test classes to minion
    7:00:33 PM PIT >> INFO : Sent tests to minion
    7:00:33 PM PIT >> SEVERE : Error generating coverage. Please check that your classpath contains modern JUnit 4 or PIT test plugin for other test tool (JUnit 5, TestNG, ...) is enabled.
    Exception in thread "main" org.pitest.util.PitError: Coverage generation minion exited abnormally. Please check the classpath and/or enable test plugin for used test tool.

Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1723
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true


Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1724
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true

        at org.pitest.util.Unchecked.translateCheckedException(Unchecked.java:20)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:105)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:51)
        at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:115)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:121)
        at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:51)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:87)
        at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
Caused by: org.pitest.util.PitError: Coverage generation minion exited abnormally. Please check the classpath and/or enable test plugin for used test tool.

Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : OpenJDK 64-Bit Server VM
Vendor : Private Build
Version : 25.252-b09
Uptime : 1723
Input -> 
 1 : -Dfile.encoding=UTF-8
 2 : -Duser.country=US
 3 : -Duser.language=en
 4 : -Duser.variant
BootClassPathSupported : true

        at org.pitest.coverage.execute.DefaultCoverageGenerator.gatherCoverageData(DefaultCoverageGenerator.java:143)
        at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:89)
        ... 6 more

FAILURE: Build failed with an exception.
  • Please post your configuration and provide other details about your project, e.g the version of junit/testng that you are using. – henry Aug 05 '20 at 07:02
  • We are currently using junit 5 and the build.gradle is groovy based – Avinash Garimella Aug 05 '20 at 09:11
  • Could you post the actual config so we can see what might be missing or incorrect? – henry Aug 05 '20 at 10:59
  • Can you please elaborate on the config details required ? The repository is on java 11 and we are currently using junit 5. – Avinash Garimella Aug 05 '20 at 11:49
  • Your gradle file (or files) will contain a section `pitest { lots of keys and values and things}` – henry Aug 05 '20 at 12:30
  • buildscript { repositories { mavenCentral() } dependencies { classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.5.1' } } plugins { id "info.solidsoft.pitest" version "1.5.1" } pitest { targetClasses = ['com.test.*'] outputFormats = ['HTML'] timestampedReports = false } Above are the configurations that i included specific to pitest plugin in build.gradle – Avinash Garimella Aug 05 '20 at 12:35
  • Can you please let me know if we can see this error for any other reasons, as this change works for me in a module and same error occurs in an other module with similar configuration and junit5PluginVersion added – Avinash Garimella Aug 05 '20 at 16:11

2 Answers2

3

As per the error message, you do not have the pitest junit 5 plugin enabled.

If you add

junit5PluginVersion = '0.12'

To the configuration the plugin will be enabled and the tests should be picked up.

henry
  • 5,923
  • 29
  • 46
  • Can you please let me know if we can see this error for any other reasons, as this change works for me in a module and same error occurs in an other module with similar configuration and junit5PluginVersion added – Avinash Garimella Aug 05 '20 at 14:38
  • I'd suggest you accept this answer, then create a new question that shows the exact error that these modules produce, and clearly sets out how they are configured. Paste the relevent config for these modules into the question, and show the structure of the overall project. – henry Aug 06 '20 at 12:32
0

The thing is that the latest version of PIT uses JUnit5, and I was using JUnit4. So, I solved it by migrating to JUnit5

if you are using maven, add the following lines to your pom file:

  <properties>
    <junit.jupiter.version>5.8.1</junit.jupiter.version>
    <junit.platform.version>1.8.1</junit.platform.version>
  </properties>
  
  <dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-suite</artifactId>
        <version>${junit.platform.version}</version>
        <scope>test</scope>
    </dependency>

</dependencies>
  • Pitest supports JUnit4 out of the box, and JUnit5 via a plugin. The statement "the latest version of PIT uses JUnit5" is not correct. – henry Aug 03 '22 at 19:54