且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 JMeter 中使用命令行参数

更新时间:2023-02-22 11:15:42

Let's start clean:

  1. In the User Defined Variables configure the variable with the name of url and the value of ${__P(url,)}

  2. In the HTTP Request sampler (or even better HTTP Request Defaults) put ${url} into "Server Name or IP" field:

  3. Run your test in command-line non-GUI mode like:

    jmeter -n -t your_script.jmx -Jurl=abcdef.com -f -l result.jtl
    

    mind this -f argument which tells JMeter to overwrite the existing results file (it might be the case you're looking into "old" results where the url property value was starting with 1)

  4. That's it, you should see the HTTP Request sampler making a call to abcdef.com in the .jtl results file. And if you change this url parameter - you will see the impact in the .jtl results file: