Jmeter 命令行执行测试

命令行执行

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:

  • -n

This specifies JMeter is to run in cli mode

  • -t

[name of JMX file that contains the Test Plan].

  • -l

[name of JTL file to log sample results to].

  • -j

[name of JMeter run log file].

  • -r

Run the test in the servers specified by the JMeter property “remote_hosts

  • -R

[list of remote servers] Run the test in the specified remote servers

  • -g

[path to CSV file] generate report dashboard only

  • -e

generate report dashboard after load test

  • -o

output folder where to generate the report dashboard after load test. Folder must not exist or be empty

The script also lets you specify the optional firewall/proxy server information:

  • -H

[proxy server hostname or ip address]

  • -P

[proxy server port]

If the property jmeterengine.stopfail.system.exit is set to true (default is false), then JMeter will invoke System.exit(1) if it cannot stop all threads. Normally this is not necessary.

eg:

jmeter -n -t C:\Users\Xuxin\Desktop\Test\系统.jmx -l C:\Users\Xuxin\Desktop\Test\系统.jtl -l C:\Users\Xuxin\Desktop\Test\系统.log -e -o C:\Users\Xuxin\Desktop\Test\系统result 

常见问题

  1. cli模式下,执行脚本时一直执行未完成

有可能是jmeter遇到线程阻塞了,或者遇到报错了,这时需要查看log文件确认是否有异常报错,然后看看内存是否足够 解决方法:

  • jmeter配置jvm参数,把内存调大
  • 设置jmeter属性中 jmeterengine.stopfail.system.exit 为true
  • 脚本中把断言,监听器相关组件给屏蔽掉

本文链接:

https://xuzi.vercel.app/archive/1640069579/

# 最新文章