米特.BeanShell 后处理器 [英] Jmeter. BeanShell PostProcessor

查看:35
本文介绍了米特.BeanShell 后处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 jmeter 中完成了 bean shell 脚本,但我没有找到任何例子,它在 jmeter 中如何有用以及哪种方式.意味着阅读采样器值等.任何人都可以用example.In解释Jmeter中的bean shell脚本我们在其中编写脚本的 beanshell 后/预处理器脚本.我正在努力解决这个问题,它的实际用途是什么.请解释一下有了这个.这对我或其他人以及理解都有很大帮助它的用法.

I have gone through the bean shell scripting in jmeter but i did not find any example of that, how it is useful in jmeter and which way.means reading the sampler values etc. Can any one explain bean shell scripting in Jmeter with example.In beanshell post/pre processor script where we write the script. I am struggling with this what is the actual usage of it .Please explain with this .it would be great help for me or others as well for understanding the usage of it.

推荐答案

如果您查看 Beanshell 后处理器的脚本"部分,您将看到以下内容:

If you look into "Script" section of Beanshell Post Processor you'll see the following:

Script(variables: ctx, vars, props, prev, data, log)

  • ctx - 代表 JMeterContext,提供对 JMeter 的访问上下文 API(有关详细信息,请参阅 JavaDoc).示例用法:

    • ctx - stands for JMeterContext, provides access to JMeter Context API (see JavaDoc for details). Example usage:

      int threadNum = ctx.getThreadNum(); // get current thread number 
      

    • vars - 代表 JMeterVariables.使用 vars 您可以获取/设置变量值.

    • vars - stands for JMeterVariables. Using vars you can get/set variable values.

      String myvar = vars.get("myvar"); // get ${myvar} variable value and store it to myvar string 
      myvar = myvar + "something"; // append "something" to myvar
      vars.put("myvar", myvar); // put new value into ${myvar} variable
      

    • props - 代表 JMeter 属性.与变量基本相同,但变量可见性仅限于当前线程组并且属性是全局的"

    • props - stands for JMeter Properties. Basically the same as variables, but variables visibility is limited to current thread group only and properties are "global"

      prev - 上一个 SampleResult 的简写.似乎正是你要找的.您可以获取/设置开始时间、结束时间、执行时间、延迟、URL、响应代码、响应消息等.有关全面信息,请参阅 JavaDoc.示例用法:

      prev - shorthand to previous SampleResult. Seems to be exactly what you're looking for. You can get/set start time, end time, execution time, latency, URL, response code, response message, etc. See JavaDoc for comprehensive information. Example usage:

      String code = prev.getResponseCode(); 
      String message = prev.getResponseMessage();
      

    • data - 包含父采样器响应数据的字节数组

    • data - byte array containing parent sampler response data

      String samplerData = new String(data);
      System.out.println(samplerData);
      

    • log - 可用于将某些内容打印到 jmeter.log 文件

    • log - can be used to print something to jmeter.log file

      log.info("This line has been written by Beanshell Post Processor");
      

    • 查看如何使用BeanShell:JMeter 最喜欢的内置组件指南了解更多细节和现实生活中的例子.

      See How to use BeanShell: JMeter's favorite built-in component guide for more details and real-life examples.

      这篇关于米特.BeanShell 后处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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