Hi. Is there a way to know if a Collection run or a Single request run is using an iteration data file or not?
Basically, my use case is that if an iteration data file is being used, the test data will be sourced from that (JSON/CSV) data file. Otherwise, the test will use Dynamic Variables for the test data instead.
Currently, the way I do this is I define an environment variable “use_data_file” flag and set it to true or false, which I then check in the script to control the logic.
Thanks, @pranavdavar for the response. I understand the variable scoping. However, what I wanted to find out is if there is a way to know via a script if an iteration data file is being used in a particular run. Below is a snippet of the code to give more context:
I am using a collection variable “use_datafile” in the if condition, which I have to set manually each time I want to toggle between using a data file vs. dynamic variables for my test data. I was hoping there is a way to determine via script if a data file is in use so I could avoid this manual setup.
The reason why I am doing this is because a data file is not available when I am just running an individual request, and not the entire collection via postman UI or Newman. Hence I need to fallback to using dynamic variables.