Tuesday, 10 January 2012

Jmeter: pass a value between threads


Find out ways to pass a value between threads (i.e. capturing a value in one of the thread and passing it to the other thread in the same test plan).

Tool Used:     JMeter: Performance testing tool.

Solution:       Sharing Variables

1)      Used Sampler : BSF Sampler
1)      Screenshot displaying the use of the BSF Sampler using  ${__setProperty(storeid, ${storeid})}; for capturing the time. The website used is http://www.mail-archive.com/jmeter-user@jakarta.apache.org/info.html for displaying the value captured in one thread to the other thread.
Screenshot 1: Displaying the BSF Sampler capturing the time value using ${__setProperty(storetime, ${__time(HMS)})};

Screenshot 2: Displaying the time captured using ${__property(storetime)} in the other thread.

Screenshot3: Successful execution of the script displaying the time value captured in Thread2

1 comment:

Anonymous said...

I have ThreadGroup1 which performs login operation and save Username and password in two different variables like

${__setProperty(USERNAMEGlobal, ${USERNAME})}
${__setProperty(PASSWORDGlobal, ${PASSWORD})}
Now in ThreadGroup2 I use these credentials.


it works fine for a single user,

but if I tried multiple users(requests).Last value overrides the previous all values and ThreadGroup2 receives only the last credentials.

I want all the credentials to be passed one by one to ThreadGroup2 and then the requests present in ThreadGroup2 should work according to all those credentials respectively.

How this can be done?

PS: I defined ramp-up period=1, Number of Users=3, loop=1

Post a Comment

Which one is right ?