javamavenpitest

How to exclude test classes from PIT mutation test with maven command line arguments?


I'm trying to run the mutation tests for all the unit tests, so I need to exclude the integration tests from the run.

I've tried these commands without success:

mvn pitest:mutationCoverage -DExcludedClasses='**IntegrationTest'
mvn pitest:mutationCoverage -DExcludedTests='path.to.integrationtest.package.**' 

This page states that there is a way to exclude with the --ExcludedClasses='**' parameter, but I guess that this one is meant for lauching it with java command intead of maven.

So my question is: Is there a parameter that I can use to exclude tests when running with mvn pitest:mutationCoverage command on commandLine


Solution

  • The parameter to exclude test classes is excludedTestClasses. This is case sensitive (standard maven behaviour), you seem to be capitalising the first letter which means it will not be recognised.

    mvn pitest:mutationCoverage -DexcludedTestClasses='com.example.integrationtests.*'
    

    Will work.

    Remember that the glob is matched again pacakge names, not file paths, and as you are invoking the goal directly you will need to have run mvn test or mvn test-compile first to ensure all required bytecode is present.

    The following link, which covers the running pitest on a project for the first time, might be useful.

    https://docs.arcmutate.com/docs/basic-maven-setup