Friday, August 12, 2016

API Automation with postman : Understand environment and collections

Okay So now we are good with request and response of REST API and how to deal it with POSTMAN.

In this post we will understand good reusable feature of postman. 

So lets look what is  Environment in postman. As tester it is necessary to test API in different environment like QA , Stage , Dev etc.  So for each environment there would be different url exist to call server data.

For exp. suppose i have one url :

QA : http://qa.jsonplaceholder.typicode.com/
Stage : http://jsonplaceholder.typicode.com/
Dev : http://dev.jsonplaceholder.typicode.com/
UAT : http://uat.jsonplaceholder.typicode.com/

Thinking.... 

So do i need to re-write each request for different environment ? Really ... ohh then its very confusing and time consuming to test...  Hey Wait ...don't do that there is solution. Postman give you environment feature through which we can use single request to test in different environment. 

Just click on Manage Environment set all URL in it.











Just check above image that need to select environment and just call key with {{keyname}} and click on send. It will get the response from QA environment.  So if user want to check data from any other environment like Stage, UAT then need to just select environment.

Okay so i think we are done with environment brief. But what about Collection ?

Hmm... Good So basically collection provide you set of API requests which can be combine with one name. So this collection can be download , share to other team or used in runner to run all request  at single click.



Suppose you have different GET, POST, PUT, DELETE request and you want to combine all request in single file then one should create collection. To create it just click on create new collection icon from sidebar and then give the name and description. Now save your all requests one by one to collection. So it will create one bunch or set of API requests. Just go through below image.





Make any request and then just simple save that request in collection.


It will save the request in collection.


As above you can share to team or run collection on single click


No comments:

Post a Comment