0
votes

I have a situation like this:

Test Plan
   Thread Group 1
      var A = 1 ( User parameters)
      HTTP request 1
      HTTP request 2 

   Thread Group 2
      var A = 2 ( User parameters)
      HTTP request 3
      HTTP request 4

I know that I can use "Run Thread Groups consecutively" to make these 2 thread run parallel. However, the problem is, because they are running parallel, sometimes var A=2 got recognized in Thread Group 1, and thus make the test case fail. What I ask, is there any way that I can still run these threads parallel and still make sure that the parameter values of these threads won't affect on each other? Thank you!

2

2 Answers

0
votes

You can use different name for the variable so that there is no conflict. Something like below:-

Test Plan
   Thread Group 1
      var A = 1 ( User parameters)
      HTTP request 1
      HTTP request 2 

   Thread Group 2
      var B = 2 ( User parameters)
      HTTP request 3
      HTTP request 4

From the jmeter documentation:-

If you have more than one Thread Group, make sure you use different names for different values, as UDVs are shared between Thread Groups. Also, the variables are not available for use until after the element has been processed, so you cannot reference variables that are defined in the same element. You can reference variables defined in earlier UDVs or on the Test Plan.

Hope this helps.

0
votes

This is not possible as JMeter Variables scope is limited to current Thread Group only so the situation where 2nd Thread Group is reading the values from 1st Thread Group User Parameters element is either a bug in JMeter or your test fails for a different reason. For example not having a User Parameters element in 2nd Thread Group I'm not getting anything as the variable value:

JMeter User Parameters

I would recommend double checking expected variable A values using Debug Sampler and View Results Tree listener combination, perhaps your configuration is vague.