2014-10-03 64 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