Problem:
Want to skip tests in maven project
Solution:
Maven 提供了跳过单元测试的能力,只需要使用 Surefire 插件的 skip 参数。
(1) 在命令行,只要简单的给任何目标添加 maven.test.skip 属性就能跳过测试
$ mvn install -Dmaven.test.skip=true
result info:
...
[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.
...
(2) 在项目的pom.xml
添加skip配置,需要在build添加 plugin
元素:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>