Today when I was debugging my JMeter script, I found a problem that confused me a lot.
userId
to 1001200
${userId}
and vars.get("userId")
. I think they should be same value, but it seems not. After run vars.put("userId", "-111")
, ${userId}
and vars.get("userId")
get different values:so it seems ${}
and vars.get()
have some difference even though their variable is same, does anyone know the reason?
Thanks in advance.
Yes, you need to follow best practices when scripting and avoid using ${value}
When using JSR 223 elements, it is advised to check Cache compiled script if available property to ensure the script compilation is cached if underlying language supports it. In this case, ensure the script does not use any variable using
${varName}
as caching would take only first value of${varName}
. Instead use :vars.get("varName")
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