newman テストを実行する Jenkins ジョブを実行しており、次のような 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 の両方の最新バージョンを使用しているので、使用するより優れた Jenkins プラグインを知っている人は共有してください。
さて、私が読んだところによると、ここでの犯人は Test Results Analyzer ではなく Newman (Postman CMD ツール) のようです。ここでこのページを見てください:
Junit形式には、ミリ秒ではなく秒単位の「時間」属性があるようです。つまり、Newman は次のように生成します: time="337" (上記でわかるように) ここで、テスト アナライザーは time="0.337" を期待しています。
そこで、「時間」属性をミリ秒から秒に変換するこの小さな Python スクリプトを実行する別のビルド ステージ (Jenkins) を追加しました。
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)
そしてそれはそれを修正しました
更新:
実際、サーバー上で実行されている Newman に古いバージョンがあることがわかりました.... newman を最新バージョン (3.5.2) にアップグレードすると、その問題が修正されます....
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加