Maven skip tests – How it works ?

The maven skip tests tutorial will show you how to skip unit tests with surefire plugin. By default, Maven will run the entire unit tests automatically when building project. You can configure maven to skip your unit tests. This tutorial also explains the two options when disabling these unit tests: the difference about skipTests and maven.test.skip.

Skip Unit Tests in Maven with argument

1. maven.test.skip: disables both running the tests and compiling the tests

You can skip unit tests via command line like below:

2. defined in pom.xml and run the package command normally.

Maven skip unit tests with surefire plugin
1. skipTests: skips running tests, but still compile them.
You can skip unit tests via command line like below:

2. To skip running the unit tests for a specified project, set the skipTests property to true.

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

That’s it!

References
Maven doc: Skip Unit Tests

Leave a Comment

*

Please share it if you found this useful
Hide Buttons