2017-05-08 36 views
0

我運行的運行一些紐曼測試,併產生JUnit測試結果文件,看起來像一個詹金斯工作:詹金斯測試結果分析儀正在呈現持續時間錯

<?xml version="1.0" encoding="UTF-8"?> <testsuites name="Basic Regression All"> <testsuite name="Login" id="02d5167b-ce9c-4ba4-9b24-e0a5c142768f" tests="2" time="628"> <testcase name="Successful Login"/> <testcase name="Auth Token is not null"/> </testsuite> <testsuite name="Account Summary" id="18773a24-2e3a-4c7d-99c3-921c4e41541b" tests="1" time="290"> <testcase name="Successfully Retreived Accounts"/> </testsuite> <testsuite name="Account Balances" id="d0817e78-8a25-4bc2-9301-3b4ef954600a" tests="1" time="337"> <testcase name="Successfully Retreived Balances"/> </testsuite> 出於某種原因,時間字段讀由「測試結果分析儀」插件爲秒而不是毫秒,如附圖所示。 任何有關這裏發生的事情的線索都會有所幫助。 另外我使用的是最新版本的兩個「測試結果分析儀」和JUnit的,所以如果有人更好詹金斯插件使用的知道請分享

Test Results

回答

1

好了,從我讀過似乎這裏的罪魁禍首是紐曼(Postman CMD工具),而不是測試結果分析器。看着這裏本頁面:

https://www.ibm.com/support/knowledgecenter/en/SSQ2R2_9.5.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html?_sm_au_=iVV1H1fVNH2HFqZH

看來,JUnit的格式在秒「時間」屬性而不是毫秒。即紐曼產生:time =「337」(正如你可以看到的那樣),因爲測試分析器期望時間=「0.337」

因此增加了另一個構建階段(詹金斯),它運行這個小的python腳本,屬性從毫秒到秒。

import os 
import xml.etree.ElementTree as etree 

#print os.getcwd() 
os.chdir('path_to/tests') 

collection = os.environ['Collection'] 
e = etree.parse(collection + '_results.xml').getroot() 

for atype in e.findall('testsuite'): 
    duration=int((atype.get('time'))) 
    atype.set('time',str(duration/float(1000))) 

f = open('fixed.xml','w') 
print >> f, etree.tostring(e) 

和固定它

UPDATE:

其實原來我對紐曼過時的版本的服務器上運行....紐曼升級到最新版本(3.5 .2)修復了這個問題.... 噢...