下载安装
去官网下载binary文件https://jmeter.apache.org/download_jmeter.cgi
解压后,进入解压目录的 /bin/ ,通过 sh jmeter 命令来启动 Jmeter。
使用jmeter GUI创建test plan
创建线程组流程:测试计划–>右键–>添加–>线程–>线程组
构造HTTP请求流程:线程组上右键–>添加–>取样器–>HTTP请求;
添加HTTP头信息管理流程:线程组上右键–>添加–>配置元件–>HTTP头信息管理;
添加断言流程:HTTP请求上右键–>添加–>断言–>BeanShell断言;
添加查看结果树流程:线程组上右键–>添加–>监听器–>查看结果树;
在本地jmeter客户端调试完成后,把test plan.jmx 文件传到测试机上执行命令
jmeter -n -t ./Test_Plan.jmx -l result.txt -e -o report
然后打开在report目录中的index.html报告查看结果
jmeter -n -t ~/Test\ Plan.jmx -l ~/jmeterFiles/testresults.jtl
使用本地jmeter客户端添加聚合报告,打开命令生成的testresults.jtl结果
1.4.4 CLI Mode (Command Line mode was called NON GUI mode)
For load testing, you must run JMeter in this mode (Without the GUI) to get the optimal results from it. To do so, use the following command options:
-t, --testfile the jmeter test(.jmx) file to run
-l, --logfile the file to log samples to
-n, --nonguirun JMeter in nongui mode
-e, --reportatendofloadtestsgenerate report dashboard after load test
-o, --reportoutputfolder output folder for report dashboard
Example
jmeter -n -t ./Test_Plan.jmx -l result.txt -e -o report