Search code examples
mavenjunitpom.xmljunit4pitest

pitest - PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG


I am trying to apply mutation testing on Apache Airavata (v0.16) using pitest. I added the following lines into pom.xml file under build plugins tag:

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.1.11</version>
 </plugin>

It gives me the following error.

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.012 s
[INFO] Finished at: 2017-03-30T14:27:44+03:00
[INFO] Final Memory: 21M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.1.11:mutationCoverage (default-cli) on project airavata-server-configuration: Execution default-cli of goal org.pitest:pitest-maven:1.1.11:mutationCoverage failed: No test library found on classpath. PIT requires either JUnit 4 (but can run JUnit 3 tests) or TestNG
[ERROR] See http://pitest.org for more details.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :airavata-server-configuration

I do not have TestNG but the junit4 path is included in the CLASSPATH. I tried providing some targetted test cases as following but it did not work either.

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.1.11</version>
    <configuration>
        <targetTests>
            <param>org.apache.archiva.common.utils*</param>
        </targetTests> 
    </configuration>
</plugin>

I have also tried the following tag but it did not help at all.

<failWhenNoMutations>false</failWhenNoMutations>

Solution

  • Archiva seems to contain a number of modules that contain no source or tests.

    The 1.1.12 release of pitest will auto-skip these (see 314), but until that is released you will need to set the skip property in each module that does not contain tests.