To skip running the tests for a particular project, set the skipTests property to true. You can also skip the tests via the command line by executing the following command: mvn install -DskipTests.
If you want to ignore a test method, use @Ignore along with @Test annotation. If you want to ignore all the tests of class, use @Ignore annotation at the class level.
According to the documentation on the Maven Surefire Plugin, -Dmaven.test.skip
should skip both compilation and execution of the tests. By contrast, -DskipTests
just skips the test execution: the tests are still compiled.
Just to be explicitly clear:
skipTests
will compile anything in the <testSourceDirectory>
, but will not execute them.
maven.test.skip
will NOT compile any tests, but WILL execute any compiled tests that made their way into the <testOutputDirectory>
.
So the behavior of the above 2 is opposite. Just wanted to point out that maven.test.skip
doesn't skip compilation AND execution if test files are unpacked/copied/etc. into <testOutputDirectory>
.
Also, depending on which version of Maven your using, there's also maven.test.skip.exec=true
which additionally skips test execution similar to skipTests.
Run a phase that doesn't include test-compile
, for example compile
.
mvn clean compile
I'm not an expert at maven, but what I use in my current project is:
mvn clean install -DskipTests=true
Depending on your use case using:
mvn compile -DskipTests=true
might work for you too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With