[英]Making Maven run all tests, even when some fail
I have a project with several modules.我有一个包含多个模块的项目。 When all tests pass, Maven test runs them all.
当所有测试都通过时,Maven 测试会运行它们。
When tests fail in the first module, maven will not continue to the next project.当第一个模块中的测试失败时,maven 将不会继续下一个项目。 I have testFailureIgnore set to true in Surefire settings, but it doesn't help.
我在 Surefire 设置中将 testFailureIgnore 设置为 true,但这没有帮助。
How do I make maven run all tests regardless of earlier failures?无论早期失败如何,如何让 Maven 运行所有测试?
From the Maven Embedder documentation :来自Maven Embedder 文档:
-fae
,--fail-at-end
Only fail the build afterwards;-fae
,--fail-at-end
仅在之后构建失败; allow all non-impacted builds to continue允许所有未受影响的构建继续
-fn
,--fail-never
NEVER fail the build, regardless of project result-fn
,--fail-never
永远不会使构建失败,无论项目结果如何
So if you are testing one module than you are safe using -fae
.因此,如果您正在测试一个模块,那么使用
-fae
是安全的。
Otherwise, if you have multiple modules, and if you want all of them tested (even the ones that depend on the failing tests module), you should run mvn clean install -fn
.否则,如果您有多个模块,并且希望对所有模块进行测试(即使是那些依赖于失败的测试模块的模块),您应该运行
mvn clean install -fn
。
-fae
will continue with the module that has a failing test (will run all other tests), but all modules that depend on it will be skipped. -fae
将继续测试失败的模块(将运行所有其他测试),但所有依赖于它的模块都将被跳过。
我刚刚找到了-fae
参数,这会导致 Maven 运行所有测试并且不会在失败时停止。
Try to add the following configuration for surefire plugin in your pom.xml of root project :尝试在根项目的 pom.xml 中为 surefire 插件添加以下配置:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
A quick answer:快速回答:
mvn -fn test
Works with nested project builds.适用于嵌套项目构建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.