views:

676

answers:

3

I have a JMeter test with 2 Thread Groups - the first is a single thread (which creates some inventory) and the second has multiple threads (which purchase all the inventory). I use BeanShell Assertions and XPath Extractors to parse the returned value (which is XML) and store variables (such as the ids of the items to be purchased).

But, values that are created in the first Thread Group, whether extracted into standard ${jmeter} type variables, or ${__BeanShell(vars.get("jmeter"))} type vars, are not available in the second Thread Group. Is there anyway to create a variable in the first Thread Group and make it visible to the second?

+2  A: 

This is not possible in JMeter, because it is not normal client behavior (sharing parameters between Threads). Instead of this use one Thread-Group with Controllers:

Thread Group
+ Create inventory
+ + XPath
+ Loop
+ + Purchase inventory
Mork0075
+2  A: 

I was not able to do this with variables (since those are local to individual threads). However, I was able to solve this problem with properties!

Again, my first ThreadGroup does all of the set up, and I need some information from that work to be available to each of the threads in the second ThreadGroup. I have a BeanShell Assertion in the first ThreadGroup with the following:

${__setProperty(storeid, ${storeid})};

The ${storeid} was extracted with an XPath Extractor. The BeanShell Assertion does other stuff, like checking that storeid was returned from the previous call, etc.

Anyway, in the second ThreadGroup, I can use the value of the "storeid" property in Samplers with the following:

${__property(storeid)}

Works like a charm!

Todd R
A: 

@ Todd R

Thanks, I've been looking for this!

James