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

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

问题描述

有人请帮助我如何使用 Jmeter 中的 jsr223 预处理器和一些 examples 编写脚本.

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

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

Any best site to get tutorial for the same.

提前致谢

西乔

推荐答案

例如:

  1. 首先,您需要选择一种脚本语言.根据 JMeter 最佳实践,最好使用 Groovy
  2. 添加 HTTP Request 并放入 google.com 进入服务器名称或 IP"
  3. 将 JSR223 PreProcessor 添加为 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.
  • 因此预处理器的目的是在请求之前做一些事情,以使系统以某种方式为请求或更改请求做好准备(例如,您有动态数量的参数或动态数量的文件要发送与请求并且不想对其进行硬编码).

    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 与 JSR223 与 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天全站免登陆