gpt4 book ai didi

maven - 即使测试失败,如何编译所有 Maven 模块,但如果任何测试失败,则整体构建失败

转载 作者:行者123 更新时间:2023-11-28 19:39:58 25 4
gpt4 key购买 nike

上下文:我想编译和测试多模块项目中的所有模块,但如果有任何失败编译或测试我希望整体构建失败

默认配置要么在第一次失败时停止,要么在测试失败后跳过模块

运行:

mvn clean install

在第一个失败的模块处停止。

如果你添加:

mvn clean install -fae //fail at end

然后运行所有模块,但如果测试失败则跳过任何依赖模块:



[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module G ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module H ............................................. SKIPPED (dependency build failed or was skipped)
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] -----------------------------------------

强制所有模块编译的另一个选项是:

mvn clean install -fn //fail never

但这会导致构建在测试失败时通过



[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] Module A ............................................. SUCCESS [15.210s]
[INFO] Module B ............................................. SUCCESS [10.923s]
[INFO] Module C ............................................. FAILED [1.731s]
[INFO] Module D ............................................. SUCCESS [3.791s]
[INFO] Module E ............................................. SUCCESS [1.488s]
[INFO] Module F ............................................. SUCCESS [9.062s]
[INFO] Module G ............................................. SUCCESS [16.324s]
[INFO] Module H ............................................. SUCCESS [4.032s]
[INFO] Module I ............................................. SUCCESS [1.690s]
[INFO] ------------------------------------------------------------------------
[INFO] Error for project: Module C (during install)
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to C:\MavenBuildDir\ModuleC\surefire-reports for the
individual test results.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] + Ignoring failures
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30 minutes 38 seconds
[INFO] Finished at: Fri May 23 16:42:08 BST 2014
[INFO] Final Memory: 39M/185M

任何人都可以建议一组选项来实现以下目标:

  1. 编译所有模块
  2. 对所有模块运行测试
  3. 如果一个模块的测试失败但代码编译依赖模块仍然被编译和测试

非常感谢回复 - 否则如果存在多个问题,我们必须在构建服务器上重复运行测试 - 会浪费很多时间。

最佳答案

我建议使用:

mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install

关于maven - 即使测试失败,如何编译所有 Maven 模块,但如果任何测试失败,则整体构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23833589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com