We can use CSV and JSON files to get data for our Postman test scripts. This is extremely useful when we need to execute a test with multiple set of Data. Also, modifying or adding any data fields will just need updating the data files which is easier than going to test script and updating test data. So, in this post we will see can we achieve this.
For testing purpose we will use a sample online REST API from, https://reqres.in/ without the need of creating any new api.
Steps to do this
- Create a new request in Postman, with Request API- https://reqres.in/api/register . Header & Body as given below:
Save the POST request.
2. Now, let us consider that we want to refer EMail ID, Password and Endpoint from the CSV File. So, click on … (3 Dots) in the Collection, Edit, and then Variables.
3. Add all the variables with their Initial Value(Can be anything).
4. Update the Post request. Parameterize this, so that going ahead values will be read from variables.
5. Create a CSV file having these 3 variables and values.
6. Goto Collection Runner, and import this data file. and finally click on Run button.
7. Now, let us do the same thing with JSON file. Create a new JSON file, and in Collection Runner use this JSON file.
I’ve added the Collection JSON and sample CSV to my github repo — please feel free to download and use.
Let me know if this was helpful. If you ever need my help, you can write in comments sections. Also, you can contact me through my LinkedIn Profile.