我正在尝试使用ANT运行Build.xml。但即使我的测试用例失败,构建输出显示为Build Succesfull,尽管它显示哪个测试用例已失败,请参阅下面的OUPUT: -
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
詹金斯并没有表示"红点"即使在项目失败后
答案 0 :(得分:3)
Ant构建状态(SUCCESSFUL
或FAILED
)与测试结果无关。当任务因意外原因失败时,构建状态通常会失败。
然而,输出显示build.xml使用TestNG任务。有一个属性告诉testng
在测试失败时设置属性。具体来说,您可以使用failureProperty
,然后检查属性是否已设置。如果设置了,您可能会失败构建,因为您会知道至少有一个测试失败了。
<testng ... failureProperty="failed.test.prop" ... />
<fail if="failed.test.prop" message="A test has failed" />