How to get value from property in BeanShell (jmeter)

耗尽温柔 提交于 2019-11-30 05:17:14

问题


I have got several thread groups. I want to use variable from the first group. In second group this var should be used in BeanShell. So: in first thread group I created BeanShell Assertion with this code:

 ${__setProperty(erroriden, ${erroriden1})};

In second thread group I have BeanShell pre-processor. If has line like this:

String[] erroriden = (vars.get("erroriden")).split(",");

I tried some variations like this:

String[] erroriden = (vars.get("__property(erroriden)")).split(",");
String[] erroriden = (vars.get("${__property(erroriden)}")).split(",");

but it doesn't work. Please help to use ${__property(erroriden)} in BeanShell pre-processor.


回答1:


In the first Thread Group:

props.put("erroriden", vars.get("erroriden1"));

In the second Thread Group:

String[] erroriden = props.get("erroriden").split(",");
  • JMeterVariables scope is limited to the current thread group only
  • JMeter Properties are usual Java Properties which are global for JVM instance
  • See How to use BeanShell: JMeter's favorite built-in component guide for more information on using Beanshell in JMeter.


来源:https://stackoverflow.com/questions/31002558/how-to-get-value-from-property-in-beanshell-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!