Many times during the build stage of the Maven application, developers will have to skip the unit test cases. This shot covers how to skip the execution of the unit test cases during the build of the Maven application.
maven.test.skip
Set the maven.test.skip
property to true
to ensure that the unit tests are not run during the build phase.
This can be done in two ways. They are as follows.
mvn clean install -Dmaven.test.skip=true
In the command above, maven.test.skip
is passed as a command-line argument.
pom.xml
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
Here, the property is set to true
via properties in pom.xml
file.
We can use the Maven profile to skip the running of the unit test cases. We need to activate the profile during the Maven build process.
We create the following profile in the pom.xml
file where we set the maven.test.skip
property to true
.
<profiles>
<profile>
<id>skiptest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
We activate the profile above during the Maven build process as follows.
maven clean install -Pskiptest