POSTMAN is an API -Application Programming Interface development tool used to build, test and modify APIs, hence we can say that Postman is an UI tool used for API testing. In postman we conduct API testing manually. It is very simple and easy tool to understand. Automation testing in Postman can be done with minimal code in a quick and easy methods. It is easy to download and install, also comes without licensing cost.
Postman supports JavaScript as programming language which is used perform various assertions to validate the tests.
This tool can be integrated with Newman tool which is used to automated tests from CLI-command line interface that can also be integrated with Jenkins for CI/CD Integration.
After installing the postman, when we click and open the tool, the following UI displays:
The left portion of the UI consists of following features:
Collections
APIs
Environments
Mock Servers
Monitors
Flows
History
Collections:
Collections in Postman is a group of requests. All the requests which user sends in will be saved in History tab by default. However if a tester wants to save all his requests as group, then creating collection is a good option. By grouping all requests, it is easier to access the requests and run. Relevant name has to be given to collection. It is similar to folder in windows, where we group files and in postman, we group requests. It is like test suite that holds set of tests.
APIs:
The commonly used http methods to communicate with REST APIs are Get, Post, Put and Delete. By clicking on API link, the user can create, update, rename and delete an API.
Environments:
An environment is a set of variables in Postman requests. Environment can be used to group a related set of values together and manage access to shared Postman data if we are working as part of a team.
In order to create an environment variable, the user need an environment where the variables are saved. Postman user clicks on environment and creates required variables with initial and current value. Environments are used to collaborate on shared resources and configure the visibility of sensitive data, including API secrets, passwords, tokens, and keys. Environments are a great way to organize data for your tests.
Mock Servers:
Mock servers in postman are used to assist with API development and testing. They are used to solve many testing problems. They help the user control what input the UI gets and how the API works. The behavior of a real API is simulated using mock servers by accepting requests and returning responses. By adding a mock server to our collection and adding examples to our request, we can simulate the behavior of a real API. When we send a request to a mock server, Postman matches the request to a saved example in our collection. Postman then responds with the data we added to the example. To view existing mock servers in our workspace, select Mock Servers in the sidebar.
Monitors:
Monitoring in Postman allows us to stay up to date with how our API is working.
Normally, when we create tests in Postman, we run them against a local build or perhaps as part of a continuous integration build. With monitors, we can run tests using staging or even production builds to make sure that certain aspects of our API are working as expected. The health and performance of our APIs is being continuously visible by Postman Monitors. Uptime monitors enable us to keep watch on a single API endpoint, while collection-based monitors enable us to run API test scripts, chain together multiple requests, and validate critical API flows. Once the monitor is running we will be alerted to any system outages or test failures, so we can identify and address issues before our API’s consumers are affected.
Flows:
It is visual tool to create API workflows. Flows are used to chain requests, handle data, and create real world work flows in our workspace. This kind of testing would typically involve calling multiple endpoints. For example, when a user wants to POST something to create new user and then call another endpoint to verify that the item has been correctly created, and is also accessible in other parts of the system. We can create simple endpoint tests that call an endpoint with various kinds of inputs and verify the results.
History:
Postman will save all the API requests in the History tab. We can go to the tab in the navigation pane and find the requests that we are interested in and add them to our collection. When user is signed in Postman, the user’s history of requests syncs across your devices. To remove all requests from our history, select the more actions icon next to the History search bar, then select Clear all.
There are two features at the top bar of Postman UI tool:
Workspace
API Network
Workspace: Workspace in Postman enables us to organize our Postman work and collaborate with teammates. We can group our projects together, with workspace acting as the single source of truth for related APIs, collections, environments, monitors, and other linked entities. By collaborating in a workspace, our edits sync with our team in team time projects. The following types of workspaces can be created:
Personal: Only logged in user can access
Private: Only invited team member can access
Team: All team members can access
Partner: Only invited partners and team members can access
Public: Everyone can view
API network:
The Postman API Network provides a central place for both API consumers and API producers to easily discover, explore, and share APIs.
The Postman API Network has three parts:
Private API Network
Private API Network is for our team only. The Private API Network provides a central directory of workspaces, collections, and APIs our team uses internally. Our Postman team can access these resources and start using them right away. By utilizing the Private API Network, we can enable developers across our organization to discover, consume, and track API development in one place.
Public API Network
Postman Public API Network is open to the entire API community. Anyone in the Postman community can access a public workspace. A public workspace can enhance a new user's onboarding experience with your API, inspire your existing users with new use cases and resources, increase your API's discovery in Postman search results, and enable us to work publicly with partners.
Partner API Network
Partner Workspaces enable us to collaborate with external partners directly in Postman. We can use Partner Workspaces to help our partners consume our team's APIs and work together on API projects. With Partner Workspaces, we can build a single source of truth and integrate our partner projects into our Postman team, setting the foundation for an efficient and productive partnership.
As we know that Postman is mainly used to create and maintain API requests. The four mainly used API requests are
GET
POST
PUT
DELETE
Let me explain the above Http methods with a simple example. Last week was Thanksgiving holiday. Since there were many sales and discounts on many items, I thought of buying Apple watch from Amazon.
GET:
First thing I did was to login to my Amazon account and searched for Apple watch “Apple watch series 7”. I was able to view varieties of Apple series 7 watches. This is nothing but GET request and the display of watches after clicking search button is the response for the get request.
POST:
After performing multiple Get requests, I choose one particular Apple watch series 7(GPS, 41MM-Red color) and moved it to my cart. This is an example for Post request.
PUT:
After reading review comments, having discussion with my family and friends, I decided to go for another model Apple watch series 8, now put request will initiated where previously selected item has been replaced by new item. Apple watch series 8 is my online shopping cart.
DELETE:
After thinking a lot, I felt I am out of budget this year so I decided that I should buy Apple watch next year, hence I removed the item from my cart. We can relate this to delete request.
I hope the reader got to know some basics about Postman UI and some common requests used in Postman which is related to real time example.
Thank you for reading my blog.