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

后端 未结 9 1624
星月不相逢
星月不相逢 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:34

    I found which I believe is the most simple way to get this done.

    Use

    Bean Shell PostProcessor
    

    Set in one Thread Group

    to set the variable (http://jmeter.apache.org/usermanual/best-practices.html#bsh_variables)

    import org.apache.jmeter.util.JMeterUtils;
    JMeterUtils.setProperty("PC_CREATED_PROMO_CODE", "value");
    

    OR if you want to set it to a value contained in another variable

    import org.apache.jmeter.util.JMeterUtils;
    JMeterUtils.setProperty("PC_CREATED_PROMO_CODE", vars.get("Extracted_PC_CREATED_PROMO_CODE"));
    

    Get in the other Thread Group

    And then from the other thread group, read it via (http://jmeter.apache.org/usermanual/functions.html#__property)

    ${__property(PC_CREATED_PROMO_CODE)}
    

提交回复
热议问题