7

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.

Ololowa QA
  • 85
  • 1
  • 1
  • 6
  • Do you get any errors? I what way "doesn't it work"? – tvgemert Jun 23 '15 at 12:46
  • Hm, seems that structure `String[] erroriden = (vars.get("${__property(erroriden)}")).split(",");` works ok. Log says: `2015/06/23 16:33:25 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.util.Random; String[] erroriden = (vars.get("6618291,2072106868,601 . . . '' : Typed variable declaration ` – Ololowa QA Jun 23 '15 at 13:33

1 Answers1

11

In the first Thread Group:

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

In the second Thread Group:

String[] erroriden = props.get("erroriden").split(",");
Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thank You, Dmitri. You helped me for the third time! – Ololowa QA Jun 23 '15 at 13:41
  • I want to clarify, could this method be used to the massive amount of data, like thousent of Ids? – Ololowa QA Jun 23 '15 at 14:23
  • Yes as long as it fits in JVM Heap. However if this code is used by many threads and amount of data is really "massive" I would recommend switching to [JSR223 Sampler](http://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler) and Groovy as a language as Beanshell has some performance limitations. See [Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For!](https://blazemeter.com/blog/beanshell-vs-jsr223-vs-java-jmeter-scripting-its-performance) guide for benchmarks and details on groovy scripting engine installation – Dmitri T Jun 23 '15 at 15:19