You may want to configure Maven to skip unit tests altogether.
Maybe you have a very large system where the unit tests take minutes to
complete and you don't want to wait for unit tests to complete before
producing output. You might be working with a legacy system that has a
series of failing unit tests, and instead of fixing the unit tests, you
might just want to produce a JAR. Maven provides for
the ability to skip unit tests using the skip
parameter of the Surefire plugin. To skip tests from the command-line,
simply add the maven.test.skip property to any
goal:
$ mvn install -Dmaven.test.skip=true
...
[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.
...
When the Surefire plugin reaches the test goal,
it will skip the unit tests if the maven.test.skip
properties is set to true. Another way to configure
Maven to skip unit tests is to add this configuration to your project's
pom.xml. To do this, you would add a
plugin element to your build
configuration.
Example 4.19. Skipping Unit Tests
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
