即使测试用例失败,也会将消息显示为ANT Build Successfull



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

Buildfile: C:UsersUC179797workspaceMy_FrameworkBuild.xml
compile:
[javac] C:UsersUC179797workspaceMy_FrameworkBuild.xml:15: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
run:
[testng] [TestNG] Running:
[testng] C:UsersUC179797workspaceMy_Frameworktestng.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也没有表示"红点"。

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

然而,输出显示build.xml使用了TestNG任务。有一个属性告诉testng在测试失败时设置一个属性。具体来说,您可以使用failureProperty,然后检查是否设置了属性。如果设置了它,您可以使构建失败,因为您知道至少有一个测试失败了。

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

相关内容

  • 没有找到相关文章

最新更新