I have a pre-request script that increments an enviroment variable to generate different ids each time a request is generated. Also, I have a runner that calls this request multiple times:
However, I’ve noticed that during the runner the environment variable is not updated, at least in the environment’s tab:
But I monitor the variable in the console log and it is incrementing correctly:
My problem is that if I prematurely stop the runner before all the requests end, the environment variable didn’t register all the sets that were executed, and such it keeps the value it had at the beginning of the execution. This may be a known issue or it might just be me using the tools in the wrong way, does anyone have any advice? I can manually set the variable to the value I need after each run but it would be better if the last line of the pre-request script
pm.environment.set(“runnerCounter”, Number(pm.environment.get(“runnerCounter”)) + 1);
always worked by setting the environment variable properly.
Also, I did check the Keep variable values as true, so as to persist any variable changes, even though I’m not sure this is necessary when it comes to environment variables.