How to skip Maven unit test

By default, when building project, Maven will run the entire unit tests automatically. If any of unit test is failed, it will force Maven to abort the building process.

$ mvn install
$ mvn package 

In real life, you may “STILL” need to build your project even some of the cases are failed.

Skip Unit Test

To skip the entire unit test, uses argument “-Dmaven.test.skip=true“.

$ mvn install -Dmaven.test.skip=true
$ mvn package -Dmaven.test.skip=true

Or define skipTests in maven-surefire-plugin.

pom.xml
   <plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.12.4</version>
	<configuration>
		<skipTests>true</skipTests>
	</configuration>
    </plugin>

Now, build the project again, the entire unit tests will be ignored.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.