How to Skip Unit Tests in Maven

In this short Maven tutorial you will learn how to build or run a Maven project and skip Unit tests.

Often when working on a project we need to build it and even run it even though our Unit test is not complete or is failing. But when using Maven install or maven package commands Unit tests will be executed and they fail the build process will be terminated.

To skip Unit tests when building a Maven project use one of the following ways.

Skip Unit Test With -Dmaven.test.skip=true

One of the ways to skip Unit tests when building a Maven project is to use -Dmaven.test.skip=true. For example, to package a maven project without running Unit tests you will issue the following command:

mvn package -Dmaven.test.skip=true

or if you use Maven Install, then:

mvn install -Dmaven.test.skip=true

Alternatively, to using -Dmaven.test.skip=true in a terminal window when running a specific Maven command, you can disable Unit tests for all Maven commands. To disable Unit tests using POM.XML add maven.test.skip to properties XML element.


If You Use maven-surefire-plugin

If you use maven-surefire-plugin then when running Maven command in the terminal window you can skip Unit tests the following way:

mvn package -DskipTests

or if you use Maven install then,

mvn install -DskipTests

Alternatively, to using -DskipTests in a terminal window when running a command you can configure to skip Unit tests in POM.xml file this way:


I hope this tutorial was helpful for you.

If you want to learn more about Maven, and you enjoy learning by following a series of step-by-step video lessons, then have a look at the below list of video courses which teach Maven.

I hope this short Android tutorial was helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *