'pitest report can't mix JUnit 4 and JUnit 5 tests

Recently, I introduced Pitest as the mutation testing tool to our team to diagnose test quality, and we loved it.

In our codebase, we have lots of preexisting JUnit 4, and now we're writing all of our new unit tests in JUnit 5. Unfortunately, even after adding Pitest JUnit 5 plugin when we try to run the mutation testing goal mvn org.pitest:pitest-maven:mutationCoverage, and it only picks up JUnit 4 tests and ignores JUnit 5 tests.

We want our report to contain JUnit 4 and 5 tests. Is there a way(hack) to generate a report mixed with JUnit 4 and 5?



Solution 1:[1]

As pointed by henry's comment, I fixed the issue by upgrading to the latest version of pitest. These versions worked for me:

            <plugin>
                <groupId>org.pitest</groupId>
                <artifactId>pitest-maven</artifactId>
                <version>1.7.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-junit5-plugin</artifactId>
                        <version>0.14</version>
                    </dependency>
                </dependencies>
            </plugin>

Solution 2:[2]

For Junit5, I use this "build" section in my pom.xml

<build>
        <plugins>
            <plugin>
                <groupId>org.pitest</groupId>
                <artifactId>pitest-maven</artifactId>
                <version>1.7.6</version>
                <dependencies>
                    <dependency>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-junit5-plugin</artifactId>
                        <version>0.15</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

and I run pi-test with this command:

 mvn test-compile org.pitest:pitest-maven:mutationCoverage

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 MauroB