1. 首先日期格式化
@echo off echo %DATE%%TIME% set datef=%date:~0,4%%date:~5,2%%date:~8%
2. 如果文件夹存在就delete掉
rd /s /q "<reportSavePath>Aggregate_report_%datef%"
3. 创建文件夹
md "<reportSavePath>Aggregate_report_%datef%"
4. 执行Jmeter命令,将JTL转为CSV
PS: 这里要下载一个cmdrunner-2.2.jar 放到JmeterHomelib下
cd <Jmeter_home_path>lib
java -jar cmdrunner-2.2.jar --tool Reporter --generate-csv <reportSavePath>Aggregate_report_%datef%Aggregate_report_%datef%.csv --input-jtl <reportSavePath>jtl_%datef%jtl_%datef%.jtl --plugin-type AggregateReport
总结完整的脚本(jmeterTest02.bat)如下:
@echo off echo %DATE%%TIME% set datef=%date:~0,4%%date:~5,2%%date:~8% rd /s /q "<reportSavePath>Aggregate_report_%datef%" md "<reportSavePath>Aggregate_report_%datef%" cd <Jmeter_home_path>lib java -jar cmdrunner-2.2.jar --tool Reporter --generate-csv <reportSavePath>Aggregate_report_%datef%Aggregate_report_%datef%.csv --input-jtl <reportSavePath>jtl_%datef%jtl_%datef%.jtl --plugin-type AggregateReport