Tag Archives: Development tool & Development environment

Maven skip unit test

You may want to configure Maven to skip unit tests entirely. Maybe you have a large system, unit tests take many minutes to complete, and you don’t want to wait for unit tests to complete before generating the final output. You may be working on a legacy system with a series of failed unit tests, and you may simply want to generate a JAR instead of fixing all the unit tests. Maven provides the ability to skip unit tests by using the Surefire plug-in’s skip parameter. On the command line, simply add the maven.test.skip attribute to any target:
  
$ mvn install -Dmaven.test.skip=true

[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.

 
If maven.test.skip is set to true when the Surefire plug-in reaches the test target, it skips the unit tests. Another way to configure Maven to skip unit tests is to add this configuration to your project’s pom.xml. You need to add the plugin element to your build.
 
< project>
[…].
& lt; build>
& lt; plugins>
& lt; plugin>
& lt; groupId> org.apache.maven.plugins< /groupId>
& lt; artifactId> maven-surefire-plugin< /artifactId>
& lt; configuration>
& lt; skip> true< /skip>
& lt; /configuration>
& lt; /plugin>
& lt; /plugins>
& lt; /build>
[…].
< /project>

From http://blog.csdn.net/symgdwyh/article/details/4289080