I’m trying to do load testing on my API and what I’m trying to achieve is hit my API with random requests. I set up a Random global variable using faker random numeric. But it seems that value gets set once and that’s it. I need it refreshed with every request. Is that doable?
Use the dynamic value expression directly in this parameter value instead of using a global variable. I believe that’s what you’re looking for.
Are you using the client version or the web version? What is the version number? You can try running it with more iterations in a local mock environment to see if it’s because the random values happen to be between 0 and 50 when the number of runs is not enough.
Client version
I tried all sorts of variations on threads and iterations but I always get the same result being hit
There was an update available to 2.4.8, but still I get the same result
I need to confer with our colleagues to pinpoint the issue and then I can provide you with a suitable reply. Thanks for your feedback.
Thank you for looking at this!
Sorry to inform you that our development engineer has stated that the usage of directly setting dynamic variable values in an “if” step is currently not supported.
The current alternative solution is to set the value of a random variable “random” in a preceding step, and then reference that value in the “if” step.
Can you explain how to set the value? This looks like you’re doing a GET request?
Yes, it can be any previous step that you may have in your test scenario. In that step, you can easily add a custom script as a post-processor. Please try to use the following provided script:
pm.variables.set("randomVar", Math.random() * 100);
console.log('randomVar', pm.variables.get("randomVar"));