gpt4 book ai didi

java - 测试失败后如何强制maven执行下一个目标

转载 作者:行者123 更新时间:2023-11-28 19:57:47 29 4
gpt4 key购买 nike

我正在使用 surefire 插件对项目运行测试,然后需要使用“站点”目标生成报告,即使有失败的测试。

问题是,默认情况下,surefire 会在测试失败的情况下强制构建失败,并且不会执行进一步的目标。所以我将以下配置设置为 surefire:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>

这很好用,“站点”目标始终执行,但在这种情况下,构建状态始终为“成功”,因此我无法设置电子邮件通知。

是否有一种正确的方法可以在“测试”目标之后执行下一个目标而不忽略 surefire 插件中的失败?

最佳答案

你可以使用:

  • -DskipTests=true 完全跳过测试执行
  • -Dmaven.test.failure.ignore=true 忽略测试失败
  • --fail-at-end 让构建在测试阶段之后 继续,并且仅在整个构建周期完成时失败(如果存在测试失败)

鉴于此声明...

This works well and the "site" goal is always executed, but in such a case the status of the build is always "Success" so that I can't set up emails notification.

...我想你想使用--fail-at-end。根据文档,它的行为是:

--fail-at-end - if a particular module build fails, continue the rest of the reactor and report all failed modules at the end instead

关于java - 测试失败后如何强制maven执行下一个目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46052425/

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