1. 忽略测试失败
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
插件参数表达式testFailureIgnore Set this to true to ignore a failure during testing. Its use * Type: boolean
* Required: No
* Expression: ${maven.test.failure.ignore}
这个表达式可以从命令行通过 -D 参数设置。
$ mvn test -Dmaven.test.failure.ignore=true
2. 跳过单元测试
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
在命令行,只要简单的给任何目标添加
maven.test.skip 属性就能跳过测试:
$ mvn install -Dmaven.test.skip=true
...
[INFO] [compiler:testCompile]
[INFO] Not compiling test sources
[INFO] [surefire:test]
[INFO] Tests are skipped.
...