Tuesday 25 April 2023

Using data files in Postman for Recursive or Repeated triggers

You can use data files to pass Postman sets of values to use in a collection run. By selecting a JSON or CSV data file in the Collection Runner, you can test your requests with multiple values as part of a single run.

Running collections with data files

·      Select Home -->File -->New Runner Tab













 ·      Now you can "drag and drop" your requests from Collection and than keep checked only request you would like to generate by a Runner setting 10 iterations (to generate 10 requests ) and delay for example to 0 (to make it as fast as possible). The requests are executed in the order it is included in the runner collection.



·       Make your file with sample data that needs to be triggered through postman

·       Below is a sample Json format File
























·      The above screenshot shows that, the file contains two sets of data that will be triggered for the each request selected.

·      Now since there are multiple triggers made to the request, the values present on the body of the request should be dynamic. So the body of the request has to be modified to get the value from the Json file.

·      Specify the variable name same as that of provided in the Json file inside {{}} in the body. Below is an example.











·      Select your data file with the Select File button.








 





·      Iterations is defaulted to 2, since we had two different sets of data in the Json file. These two sets of data will be used to trigger all the request marked in the runnable collection used.

·      Click on the button Run Trigger using Data files.

·      We can see the summary and results using the View summary / View results Tab.








 










·      Test scripts can be used in the Test area of the request if required for any specific scenarios(Optional)



 







More details can be found in Using data files in Postman

No comments:

Post a Comment