gpt4 book ai didi

maven - 尽管单元测试失败,但 Jenkins Maven 构建报告成功

转载 作者:行者123 更新时间:2023-12-04 12:06:29 30 4
gpt4 key购买 nike

我在 Jenkins 中使用 Maven 3.2.3、JUnit 4.12 和 SureFire 2.18.1。我有一个使用以下 Maven 选项设置的多模块 Maven 作业:

clean install -U -e -P qa -Dci -DskipITs

然而,当我运行我的 Maven 构建时,虽然我的一个 JUnit 测试失败了,但 Maven 模块本身会报告“SUCCESS”(之后的输出)......
Executing Maven:  -B -f /var/lib/jenkins/workspace/subco/subco/pom.xml clean install -U -e -P qa -Dci -DskipITs




———————————————————————————
T E S T S
-------------------------------------------------------
Running org.mainco.subco.user.domain.UserTest
Tests run: 24, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.049 sec <<< FAILURE! - in org.mainco.subco.user.domain.UserTest
testHasRoleNullRoles(org.mainco.subco.user.domain.UserTest) Time elapsed: 0.006 sec <<< FAILURE!
java.lang.AssertionError: Failed to indicate we found right role for user.
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at



[INFO] Tests are skipped.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ othersubmodule ---
[INFO] Installing /var/lib/jenkins/workspace/subco/subco/othersubmodule/target/othersubmodule.war to /var/lib/jenkins/.m2/repository/org/mainco/subco/othersubmodule/83.0.0-SNAPSHOT/othersubmodule-83.0.0-SNAPSHOT.war
[INFO] Installing /var/lib/jenkins/workspace/subco/subco/othersubmodule/pom.xml to /var/lib/jenkins/.m2/repository/org/mainco/subco/othersubmodule/83.0.0-SNAPSHOT/othersubmodule-83.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] subco ....................................... SUCCESS [4.849s]
[INFO] database .......................................... SUCCESS [18.340s]
[INFO] session ........................................... SUCCESS [6.601s]
[INFO] main .............................................. SUCCESS [8:00.887s]
[INFO] mainclient ........................................ SUCCESS [4:01.490s]
[INFO] orders ............................................ SUCCESS [50.831s]
[INFO] SBD myproject Webapp .................................. SUCCESS [1:45.484s]
[INFO] subco Admin Module .......................... SUCCESS [1:01.318s]
[INFO] Other Submodule ................................ SUCCESS [6.162s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16:20.351s
[INFO] Finished at: Thu Aug 20 21:17:57 UTC 2015
[INFO] Final Memory: 76M/748M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/orgsclient/pom.xml to org.mainco.subco/orgsclient/83.0.0-SNAPSHOT/orgsclient-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/orgsclient/target/orgsclient.war to org.mainco.subco/orgsclient/83.0.0-SNAPSHOT/orgsclient-83.0.0-SNAPSHOT.war
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/pom.xml to org.mainco.subco/subco/83.0.0-SNAPSHOT/subco-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/myproject/pom.xml to org.mainco.subco/myproject/83.0.0-SNAPSHOT/myproject-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/myproject/target/myproject.war to org.mainco.subco/myproject/83.0.0-SNAPSHOT/myproject-83.0.0-SNAPSHOT.war
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/database/pom.xml to org.mainco.subco/database/83.0.0-SNAPSHOT/database-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/database/target/database-83.0.0-SNAPSHOT.jar to org.mainco.subco/database/83.0.0-SNAPSHOT/database-83.0.0-SNAPSHOT.jar
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/othersubmodule/pom.xml to org.mainco.subco/othersubmodule/83.0.0-SNAPSHOT/othersubmodule-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/othersubmodule/target/othersubmodule.war to org.mainco.subco/othersubmodule/83.0.0-SNAPSHOT/othersubmodule-83.0.0-SNAPSHOT.war
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/sbadmin/pom.xml to org.mainco.subco/sbadmin/83.0.0-SNAPSHOT/sbadmin-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/sbadmin/target/sbadmin.war to org.mainco.subco/sbadmin/83.0.0-SNAPSHOT/sbadmin-83.0.0-SNAPSHOT.war
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/main/pom.xml to org.mainco.subco/main/83.0.0-SNAPSHOT/main-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/main/target/main.jar to org.mainco.subco/main/83.0.0-SNAPSHOT/main-83.0.0-SNAPSHOT.jar
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/main/target/main-tests.jar to org.mainco.subco/main/83.0.0-SNAPSHOT/main-83.0.0-SNAPSHOT-tests.jar
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/orders/pom.xml to org.mainco.subco/orders/83.0.0-SNAPSHOT/orders-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/orders/target/orders.jar to org.mainco.subco/orders/83.0.0-SNAPSHOT/orders-83.0.0-SNAPSHOT.jar
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/session/pom.xml to org.mainco.subco/session/83.0.0-SNAPSHOT/session-83.0.0-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/subco/subco/session/target/session.jar to org.mainco.subco/session/83.0.0-SNAPSHOT/session-83.0.0-SNAPSHOT.jar
Sending e-mails to: sb-engineers@evotext.com laura.curry@evotext.com deb.arsenault@evotext.com bob.bean@evotext.com laredotornado@live.com

channel 已停止
发送电子邮件至:list@myco.com
警告:您没有为构建提供访问控制的插件,因此退回到允许触发任何下游构建的传统行为
完成:不稳定

如果其中一个单元测试失败,如何让 Maven 模块报告 FAILURE?我意识到 Jenkins 中的整体构建报告为 UNSTABLE,但为了便于阅读,我希望只有在一切都通过时才显示 SUCCESS。

编辑:这是肯定的插件配置
                    <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<reuseForks>true</reuseForks>
<argLine>-Xmx2048m -XX:MaxPermSize=512M -noverify -XX:-UseSplitVerifier ${argLine}</argLine>
<skipTests>${skipAllTests}</skipTests>
</configuration>
</plugin>

最佳答案

这个答案基本上是@spoonybard896 在评论中建议的。

添加 -Dmaven.test.failure.ignore=falseMAVEN_OPTS .可以在 Jenkins Job 的 Build -> Advanced 部分添加。

通常这应该是默认值,但对于 Jenkins 和 Maven 作业,it isn't so .对于那些,此属性实际上设置为 true除非你自己设置。

(免责声明:从 this answer 查找确切的 Jenkins 步骤)。

关于maven - 尽管单元测试失败,但 Jenkins Maven 构建报告成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32141662/

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