写本文章主要是因为我在用ant执行时,只生成了jtl,没有生成html报告(目前还没解决,后面解决了会更新)。然后我找了其他方法,直接用jmeter 命令运行:
jmeter -n -t C:\apache-jmeter-testcases\GYTestPlan.jmx -l C:\apache-jmeter-testcases\report\test.jtl -e -o C:\apache-jmeter-testcases\report\html
运行成功界面:
生成报告情况:
html报告:
在执行过程中,踩过以下的坑:
1、运行的时候,提示 “An error occurred: Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property errorlevel=1”
解决办法:在jmeter的jmeter.properties配置文件中输出格式 改成 csv
jmeter.save.saveservice.output_format=csv
2、提示“does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly when generating report”,解决办法如下:在jmeter.properties配置文件中增加一下内容:
jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.timestamp_format=ms
jmeter.save.saveservice.timestamp_format=yyyy-MM-dd HH:mm:ss
jmeter.save.saveservice.print_field_names=true
3、提示“An error occurred: Cannot write to 'C:\apache-jmeter-testcases\report' as folder is not empty”
解决办法:需要保证-o 后的报告保存路径是一个空文件夹(如:C:\apache-jmeter-testcases\report 下的没有)
最后,祝你好运~