Reputation: 370
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
Upvotes: 3
Views: 3755
Reputation: 6096
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
Upvotes: 3
Reputation: 441
According to the Maven plugin quickstart documentation for Pitest there's a excludedTestClasses
configuration parameter where you can specify which tests should be excluded. So assuming all your integration tests are in the same package you should be able to do something like this:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>LATEST</version>
<configuration>
<excludedTestClasses>
<param>path.to.integrationtest.package*</param>
</excludedTestClasses>
</configuration>
</plugin>
EDIT:
In order to have it accessible on the command line you could create a profile activated by a property, and use that property to set the plugin configuration. Maven merges the configuration by default, giving you the result you want.
Something like this (untested):
<profiles>
<profile>
<activation>
<property>
<name>excludedTestPackage</name>
</property>
</activation>
<build>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<configuration>
<excludedTestClasses>
<param>${excludedTestPackage}</param>
</excludedTestClasses>
</configuration>
</plugin>
</build>
</profile>
</profiles>
And to activate it when invoking Maven:
mvn pitest:mutationCoverage -DexcludedTestPackage=path.to.integrationtest.package*
Upvotes: 1