How do I pass a variable from one Thread Group to another in JMeter

后端 未结 9 1598
星月不相逢
星月不相逢 2020-11-27 04:54

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

9条回答
  •  独厮守ぢ
    2020-11-27 05:41

    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!

提交回复
热议问题