2014-10-03 33 views
0

我想用ANT运行Build.xml ..但即使当我的测试用例失败时,构建输出显示为Build Succesfull,尽管它显示了哪个测试用例已经失败,请参见下面的OUPUT: -显示消息为ANT构建成功,即使测试用例失败

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 

詹金斯多年平均值显示“红点”项目失败

回答

3

Ant构建状态(SUCCESSFULFAILED)即使是不相关的结果测试。由于意外原因,任务失败时,构建状态通常会失败。

不过,输出显示build.xml使用TestNG任务。有一个属性告诉testng设置一个属性,以防测试失败。具体而言,您可以使用failureProperty,然后检查属性是否已设置。如果已设置,则可能会使构建失败,因为您知道至少有一个测试失败。

<testng ... failureProperty="failed.test.prop" ... /> 

<fail if="failed.test.prop" message="A test has failed" /> 
+0

嗨感谢您的评论....但正因为如此message.ie“构建全成”,我詹金斯甚至不表明项目的失败作为一个即“红点” – Kiran 2014-10-03 15:57:38

+1

@Kiran你有没有尝试答案中提到的'失败'任务?此任务的全部目的是导致构建失败,即输出将显示“BUILD FAILED”。 – manouti 2014-10-03 17:04:27

相关问题