Reputation: 69
I have set the number of users to 5 and i have 3 threads running in a test plan. My issue is when i pass the variable from 1 thread to another, for all 5 users, its passing the same value instead of 5 diff values. I am using Bean shell assertion to pass variable to other thread
Used beanshell assertion to pass variables
${__setProperty(name, ${name})};
${__setProperty(range, ${range})};
and used the property function in next thread
"name": "${__property(name)}",
"range": "${__property(range)}",
If you see the Payload, name and range value is always same for 5 users:
POST data:
{
"name": "testA",
"range": "range-A",
}
Expected result is 5 users should have diff names
{
"name": "testA",
"range": "range-A",
}
{
"name": "testB",
"range": "range-B",
}
{
"name": "testC",
"range": "range-C",
}
Upvotes: 0
Views: 517
Reputation: 1999
-Use groovy instead of beanshell for performance.
-Use preprocessors or postprocessors instead of beanshell assertion.
-Assuming it is 5 users and 3 Thread groups and not 5 users and 3 threads.
-There is a difference in property and variable as described below:-
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads
So, if your setting variable as property then it becomes common to all and every thread will receive the same value.
To pass value from first thread group to the next, you can also use InterThread-Communication
Considering you know what values need to be send then use CSV Data set config. If data is getting fetched from post request, then use post processor to fetch the value and pass it further.
Hope this helps.
Upvotes: 0