Jmeter | Passing variables between threads

Priyank Shah
Aug 23, 2017 · 2 min read


As an automation tester, I would like to pass one variable of one thread group to another thread group. (Sharing variables between threads)


JMeter variables have thread scope. This is deliberate, so that threads can act independently. However sometimes there is a need to pass variables between different threads, in the same or different Thread Groups.

Problem Statement


One way to do this is to use a property instead. Properties are shared between all JMeter threads, so if one thread sets a property, another thread can read the updated value.

Solution to the Problem Statement

Note: Before executing the test plan do not forget to set check-box “Run Thread Groups consecutively”. It is a must for executing Thread Groups one by one.

  1. Regular Expression Extractor:

Use Regular Expression to extract user_key” & “user_id” and stored in different variables.

2. BeanShell Assertion:

Result of Regular Expression will be stored in variable user_id. And now shuffle on over to BeanShell Assertion.

Explanation of ${__setProperty(user_id,${user_id})}

  • The setProperty function sets the value of a JMeter property.
  • user_id — name of the property that will be set.
  • ${user_id} — is the variable that was stored in Regular Expression Extractor.

3. Get the value of the Property:

Get the value of variables using _property function which returns the value of a JMeter property. ${__property(user_id)}

If you enjoyed the article, do me a favor and smack the 👏👏 👏 multiple times — your support means the world to me!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store