New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable handling is not the same in request builder and runner #6352
Comments
This should not work at all. By using pm.variables.set you address to collection variables, and they are not allowed to be modified while collection run. They are to be pre-defined and you may only read them.
|
@m3dbedb: what method would you propose for the described use case? Similar behaviour in both request builder and runner would be very desireable. |
I use environmet variable to store test stand settings, and globals for temporary data (I understand that it sounds odd, but I keep environment parameters in environment variables, and it is consistent). |
@m3dbedb sorry, but what do you mean by that? How does that help with the example above for a default test case & default value? |
@klemens-u, in my previous post edit I missed issue and passed wrong advice. |
@m3dbedb ok, no problem :-) |
This is intended behaviour of Postman. I suggest that you unset that variable right after testing so that any of them set in previous scripts do not affect the next. Closing. |
Situation:
Environment variable:
"status_code_default" = 200
Collection Test (Collection -> Edit -> Tests):
So this adds a default test to every request checking if the status code = 200.
Now for a specific request we want to override the default value:
Request -> Pre-request Script:
pm.variables.set("status_code_default", 400);
This way we can assert that the request expects code 400.
This works fine in the request builder.
Problem: it does not work for subsequent request in runner. The default value from the environment is not loaded before the next request. Therefore the last custom value leaks into the next request.
For example for the subsequent request I expect code 200 again, but in the runner it is still set to code 400.
Postman v7.0.9
Ubuntu 16.04
The text was updated successfully, but these errors were encountered: