How to use Postman to automate API tests
Postman is a collaboration platform for API development. If you are a software developer and need to develop, test, and maintain an API or a set of API endpoints, you will find Postman very helpful. In this article, we won’t introduce too many concepts about API and Postman but will focus on some of the most common use cases which shall be handy for your development work.
You can use the web version of Postman directly, or you can download and install it on your computer. The desktop version can have some features that may not yet be supported by the web version.
Once you open the web or desktop version of Postman, on the Home page, click Workspaces to check the available workspaces. In Postman, a workspace allows you to organize your Postman work and collaborate with teammates. In a workspace, you can group your projects together, which includes collections, environments, mocks, monitors, etc. In this article, we will only work in the default workspace which is called My Workspace. Once you know how to make API tests by yourself, it will be very straightforward to collaborate with your colleagues in some shared workspace.
When you are in a workspace, you can see various tabs such as Collections, Environments, Mock Servers, Monitors, etc. The most important concept in Postman is collection which is a group of saved requests that can be organized into folders. When importing or exporting some APIs in Postman, it has to be done by collections. When you run some APIs on the command line with Newman, even if it’s a single API, you need to put it in a collection.
You can click the plus (+) sign or the New button to create a new collection. Give it a meaningful name and save it. In this article, I will use the country and weather APIs for demonstration, so I will call the collection “Country and Weather”. Once the collection is created, you will be prompted to add a request. Alternatively, you can click the three dots (…) on the right side and choose “Add a request”. Postman is very user-friendly and the same utility can be found in multiple places. Feel free to poke around and get familiar with it.