In my BSF preprocessor (language javascript), I am generating post data such as
var totalCustomer = 2;
var data = { "customers": [] };
for(i=1; i<=totalCustomer; i++){
// in all iteration getting same value for ${__UUID}
var customer = {
"id": "${__UUID}"
}
data.customers.push(customer);
}
vars.putObject("data",JSON.stringify(data));
I guess it is compiled once and looked up for the value in subsequent iterations.
Is there any way I can generate different guid
using ${__UUID}
for each iteration?
Step to implement the logic for passing the variable value to another Thread Group: Add a 'Regular Expression Extractor' post-processor as a child element of 1.1 HTTP Request (Fetcher) and fetch the value in a variable (say employeeID) Add a 'BeanShell Assertion' and write ${__setProperty(valueToPass,${employeeID})}
First we create a setup thread group and under that user defined variables. We then define the specific environment variables to use across the test plan. preprod. With the user defined variables set we then need to write them to global variables (properties).
${__UUID}
with UUID.randomUUID().toString()
. Don't inline JMeter variables and functions into script, it's not very good practice and may lead to unexpected behavior (as in your case). Particular for your scenario it's better to call UUID class methods directly.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With