2016-03-03 95 views

回答

4

根據您的項目創建一個JMeter的輸出文件:

jmeter -n -t ./project.jmx -l testresult.jtl 

這將加載該文件project.jmx,運行測試並將結果保存到testresult.jtl

一旦你有很多這樣的結果文件,你可以使用下面的腳本將它們合併:

#!/bin/bash 

echo "Combines all results from files called testresult*.jtl into one file called merged.jtl" 
echo "If merged.jtl exists, it will be overridden" 

cat testresult*.jtl > merged.jtl 

# Remove boundaries between tests 
sed 's_<\/testResults>__g' merged.jtl > /tmp/sedmerged1 
sed 's_<?xml version=\"1.0\" encoding=\"UTF-8\"?>__g' /tmp/sedmerged1 > /tmp/sedmerged2 
sed 's_<testResults version=\"1.2\">__g' /tmp/sedmerged2 > /tmp/sedmerged3 

# Add wrappers 
echo "</testResults>" >> /tmp/sedmerged3 
sed '1i <?xml version="1.0" encoding="UTF-8"?><testResults version="1.2">' /tmp/sedmerged3 > merged.jtl 

該腳本將創建一個名爲merged.jtl

完成。