1、首先需要准备好 .jmx 脚本
2、修改jmeter.properties文件(把注解去掉,报告中才能展示所需信息)
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.assertion_results_failure_message=true
jmeter.save.saveservice.assertion_results=none
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.response_data=false
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
# Only available with HttpClient4
jmeter.save.saveservice.connect_time=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.encoding=false
jmeter.save.saveservice.bytes=true
# Only available with HttpClient4
jmeter.save.saveservice.sent_bytes=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.filename=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.idle_time=true
jmeter.save.saveservice.timestamp_format=ms
jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS
sampleresult.timestamp.start=true
3、打开cmd 命令窗口
输入下面的命令:
jmeter -n -t E:/jmeterData/jmeter_Script/hszspay.jmx -l result.jtl -e -o E:/jmeterData/jmeter_Script/result
-n :以非GUI形式运行Jmeter
-t :hszspay.jmx 脚本路径
-l :运行结果保存路径(.jtl),此文件必须不存在
-e :在脚本运行结束后生成html报告
-o :保存html报告的地址, 此文件必须不存在
Error in NonGUIDriver java.lang.IllegalArgumentException: Results file:report.jtl is not empty
解决办法1:原因是report.jtl不能为空,在网上找了好多办法都不适用,本身想着把report.jtl直接删掉,没有找到路径,最后就每次删完我新建的Report文件夹下面的文件,再次执行命令的时候把report.jtl重新进行命名就可以了解决办法2:在使用命令的时候将report.tjl也指定对应的目录,这样删除的时候就可以找到了,命令如下:jmeter -n -t F:\jmter_test\car_m.jmx -l F:\jmter_test\report.jtl -e -o F:\jmter_test\Report