Skip to main content

Featured

How to Visualize your JSON 🕵🏼?

A simple way to view and segregate the complex JSON Hello Peeps, Welcome back to another blog 😉. I hope everything is going well for you. Many people prefer the JSON format for APIs, databases, and other applications for a variety of reasons. Some JSON requests or responses are simple and only contain a few objects. On numerous occasions, you may be required to handle a complex response. I wrote a blog about parsing complex responses before using https://jsonpathfinder.com/ In most cases, however, you will need to further investigate your JSON payload or responses for various reasons and analytical purposes. Are you a visual learner or a fan of mind maps? Then you will undoubtedly fall in love with this tool ❤️ JSON Crack I recently came across this tool and found it’s worth sharing with the community 👓 Once you land on the home page, click “GO TO EDITOR” Now you will see a sample JSON beatified and visualized. To visualize it, clear the left side pane and paste your JSON. For instan

How to implement Data Driven Approach in Postman?

 

Hello Peeps,

Welcome back!!

Postman allows us to execute requests in a collection through the collection runner and while execution we can provide a data set in the form of JSON or CSV that are used while running the requests inside the collection.

When To Use Data Variables?

Data variables are used while we are working with multiple data-sets and they exist only during the execution of an iteration from the data file.

Data-driven testing is when we have one test that we run multiple times with different data variables.

Let the body of the API be:

{
“email”: “{{email}}”,
“password”: “{{password}}”
}

Add your tests in Tests tab:

pm.test(“Status code is 200” , function(){
pm.response.to.have.status(200);
});

Using JSON file:

  1. Create a JSON file, for bulk data creation you can use “Mockaroo” tool and read this blog to know more about it.
  2. Add email and password keys in JSON file separated by a comma
  3. Add the possible values for email and password
[
{
“email”: “eve.holt@reqres.in”,
“password”: “pistol”
},
{
“email”:”charles.morris@reqres.in”,
“password”:”pistol”
},
{
“email”:”tracey.ramos@reqres.in”,
“password”:”pistol”
}
]

4. To get variables from JSON file, just make sure to match the key names in the body with the JSON file keys

5. Navigate to the Collection or Folder level. Click the Run button

6. Collection Runner window will appear

7. Select the file you need to run. The preview button will display the preview of the JSON file

8. Once selected, the iterations are the no. of data rows in a JSON file that is displayed, you can edit this.

9. Click on the Run button.

10. The Result window will be displayed.

Using CSV file:

Same like JSON, you can use the data from the csv file as well. It’s the same process and the csv file looks like below:

So far the Data driven method in Postman supports JSON and CSV.

It’s as simple as that!!

Hope this solves most of our problem and the same will work using newman too. You just need to pass the data file along with your original command using -d.

Take care and see you soon in the next post!!

---------------------------------------------------------------------------------------------------------------------------

Originally published in https://bpricilla.medium.com/data-driven-approach-in-postman-e75f060f506c


Comments

Popular Posts