如何在JMeter中使用命令行参数 [英] How to Use Command Line Parameters in JMeter

查看:643
本文介绍了如何在JMeter中使用命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jmeter测试API,我想从终端参数化项目的路径,然后在JMeter中使用此参数。



我通过命令行发送的参数:



./ jmeter -n -t your_script。 jmx -Jurl = abcdef.com



我在用户定义变量中使用的参数:



$ {__P(url)}



但是,当我在JMeter中运行自动化程序时,我的测试脚本将不会转到已定义的URL。当我检查请求正文时,我看到POST 采样器(甚至更好的




  • I'm using Jmeter for testing APIs and I want to parametrize the project's path from the terminal and then I want to use this parameter in JMeter.

    The parameter that I've sent via Command Line :

    ./jmeter -n -t your_script.jmx -Jurl=abcdef.com

    The parameter that I've used in User Defined Variables :

    ${__P(url)}

    But when I run my automation in JMeter, my test scripts are not going to URL that's been defined. When I check the request body, I see POST https://1 as URL.

    Please see the attached photos. https://mylifebox.com/shr/3df5bb35-cf43-4488-b20b-5c2d59656212&language=en

    解决方案

    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:

    这篇关于如何在JMeter中使用命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆