如何在jmeter中使用jsr 223预处理程序? [英] how to use jsr 223 preprocessor in jmeter?

查看:2163
本文介绍了如何在jmeter中使用jsr 223预处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请有人帮我在Jmeter中使用jsr223预处理器和一些examples进行脚本编写.

Someone please help me how to do scripting using jsr223 preprocessor in Jmeter with some examples.

任何获得相同tutorial的最佳网站.

Any best site to get tutorial for the same.

预先感谢

SIJO

推荐答案

例如:

  1. 首先,您需要选择一种脚本语言.根据 JMeter最佳做法,最好使用 HTTP请求,然后将google.com放入服务器名称或IP" "
  2. 将JSR223预处理器添加为HTTP请求的子代,并将以下行放入脚本"区域:

  1. First of all you need to choose a scripting language. As per JMeter Best Practices it's better to use Groovy
  2. Add HTTP Request and put google.com into "Server Name or IP"
  3. Add JSR223 PreProcessor as a child of the HTTP Request and put the following line into "Script" area:

sampler.setDomain("example.com");

  • 添加查看结果树侦听器并运行测试
  • 检查请求"和响应数据"选项卡,确保请求确实到达了example.com而不是google.com
  • 禁用或删除JSR223预处理器
  • 再次运行测试.
  • 确保已通过查看结果树"侦听器将请求发送到了google.com.
  • Add View Results Tree listener and run the test
  • Inspect "Request" and "Response Data" tabs and ensure that request did go to example.com instead of google.com
  • Disable or delete JSR223 PreProcessor
  • Run the test again.
  • Ensure that request went to google.com via View Results Tree listener.
  • 因此,PreProcessors的目的是在请求之前做 ,以便使系统为请求或更改请求做好准备(例如,您具有要发送的动态参数数量或动态文件数量)与请求,并且不想对其进行硬编码).

    So the purpose of PreProcessors is do something before request in order to make the system prepared for the request or change request somehow (for instance you have dynamic number of parameters or dynamic number of files to send with the request and don't want to hardcode it).

    在上面的示例中,sampler代表 HTTPSamplerProxy ,有关可用方法和字段,请参见JavaDoc.另请查看 Beanshell vs JSR223 vs Java JMeter脚本:关于性能的问题,您一直在等待!指南,以获取有关groovy引擎安装和脚本最佳实践的详细信息.

    In above example sampler stands for HTTPSamplerProxy, see JavaDoc for available methods and fields. Also check out Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for details on groovy engine installation and scripting best practices.

    这篇关于如何在jmeter中使用jsr 223预处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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