In Maven, to skip running unit tests, uses this -Dmaven.test.skip=true

By default, when building project, Maven will run the entire unit tests automatically. If any unit tests is failed, it will force Maven to abort the building process. In real life, you may STILL need to build your project even some of the cases are failed.

1. maven.test.skip=true

1.1 To skip unit tests, uses this argument -Dmaven.test.skip=true


$ mvn package -Dmaven.test.skip=true

1.2 Or defined in pom.xml and run the package command normally.



$ mvn package
#no test

2. skipTests

2.1 Alternatively, use this surefire -DskipTests


$ mvn package -DskipTests

2.2 Or this.



3. maven.test.skip vs skipTests

The core difference :

  1. maven.test.skip is a feature of Maven itself, skip compile tests, skip run test, just ignore any test processes.
  2. skipTests is a feature of surefire plugin, compile the tests but skip running it.

Normally, I prefer maven.test.skip


  1. Skipping Tests