【问题标题】:Shows the message as ANT Build Successfull,even if the testcases are failed显示消息为 ANT Build Success,即使测试用例失败
【发布时间】:2014-10-03 23:59:47
【问题描述】:

我正在尝试使用 ANT 运行 Build.xml。但即使我的测试用例失败,构建输出也会显示为 Build Succesfull,尽管它显示了哪个测试用例失败,请参阅以下输出:-

Buildfile: C:\Users\UC179797\workspace\My_Framework\Build.xml
compile:
[javac] C:\Users\UC179797\workspace\My_Framework\Build.xml:15: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
run:
[testng] [TestNG] Running:
[testng] C:\Users\UC179797\workspace\My_Framework\testng.xml
[testng] Starting ChromeDriver (v2.9.248315) on port 6722
[testng] log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
[testng] log4j:WARN Please initialize the log4j system properly.
[testng] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[testng] 2
[testng] ===============================================
[testng] Suite
[testng] Total tests run: 2, Failures: 1, Skips: 0
[testng] ===============================================
[testng] The tests failed.
BUILD SUCCESSFUL
Total time: 50 seconds

即使项目失败了,Jenkins 也不显示“红点”

【问题讨论】:

    标签: selenium ant build


    【解决方案1】:

    Ant 构建状态(SUCCESSFULFAILED)与测试结果无关。当任务因意外原因失败时,构建状态通常为失败。

    尽管如此,输出显示 build.xml 使用了TestNG 任务。有一个属性告诉testng 设置一个属性以防测试失败。具体来说,您可以使用failureProperty 并随后检查是否设置了该属性。如果设置了它,您可能会导致构建失败,因为您知道至少有一个测试失败了。

    <testng ... failureProperty="failed.test.prop" ... />
    
    <fail if="failed.test.prop" message="A test has failed" />
    

    【讨论】:

    • 您好,感谢您的评论......但仅仅因为这条消息。即“Build SuccessFull”,我的 Jenkins 甚至没有将项目指示为失败的项目,即在“红点”中
    • @Kiran 您是否尝试过答案中提到的fail 任务?此任务的全部目的是导致构建失败,即输出将显示BUILD FAILED
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-21
    • 2017-01-25
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    相关资源
    最近更新 更多