Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

BeanShell Sampler in JMeter

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

BeanShell is a lightweight scripting language written in pure java.

BeanShell Sampler can be scripted in jmeter.

There are three common built-in variables:

log

Used to print logs in jmeter.log, you can print strings, variables

log.info("hello world");

vars

Used to access jmeter thread variables, usually used to access string content, but also to access objects

vars.get()

String mykey = vars.get("keyname"); ----Get the value of the thread variable name keyname and save it in mykey

String cookie11 = vars.get("COOKIE_JSESSIONID");

vars.put()

vars.put("keyname", "value"); ----Save value to jmeter thread variable keyname

vars.put("fcy", "tester");

Thread group--Add--Sampler--Debug Sampler, run, view Debug Sampler through the result tree, you can see all saved variables

Save it to a variable so that you can use it later: fcy = vars.get("fcy"), or fcy = "${fcy}"

Note: For fcy = "${fcy}", variables can be used in this way, but attributes cannot.

Properties can only be used with props.get(), the_P function, or the_property function.

3. props

Access jmeter attribute, key and value in parameters are in string form

ymd = props.get("START.YMD"); gets the value of attribute START.YMD (script start date)

props.put("PROP1", "1234");

Store 1234 in global attribute PROP1

Note: For attribute variables (global variables), generally restart jmeter to take effect, after using props, it is best to restart jmeter.

access attribute tom

Thread group--Add--Sampler--Debug Sampler, run, view Debug Sampler through the result tree, you can see all saved properties

4. Difference between thread variables and attributes:

Thread variables are local variables; attributes are global variables.

For attribute variables (global variables), generally restart jmeter to take effect, after using props, it is best to restart jmeter.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report