Before stepping into API Testing using Postman, let's check the various tools which are frequently used.
- REST-assured - It is considered as one of the best tools for testing APIs in Java/.NET.
- Postman - After REST-assured, the next API testing tool is Postman. It offers web and desktop version application, and can also be used for testing API services.
- SoapUI - This testing tool that allows developers to test REST, SOAP, GraphQL, and Web Services. It also gives a lot of unique features like test reports, SOAP API testing, and others.
- Apache Jmeter - It is another open-source software for load and performance testing of applications also widely used for functional API testing.
and so on...
What is an API?
API stands for Application Programming Interface, which is used to stabilize the interaction between two different applications by using any mode of communication.
API testing involves testing the collection of APIs and checking if they meet expectations as per functionality, reliability, performance, and security and returns the correct response.
API testing is also used to determine whether the output is well-structured and useful to another application or not, checks the response based on the input parameters to the request, and checks the amount of time API is taking to retrieve and authorize the data.
But Why API Testing? What do we derive from this?
Web applications today are fueled by REST-based Web Services. So, it is crucial to test APIs as part of the continuous integration process to reduce errors, improve predictability, and catch those bugs!
In the context of API development, Postman is a great tool to test APIs.
Postman is an application for testing APIs by sending a request to the webserver and getting the response back.
It allows users to set up all the headers and cookies the API expects and checks the response. A test in Postman is fundamentally a JavaScript code, which runs after a request is sent and a response has been received from the server.
Prerequisites:
Download and install Postman via postman.com/downloads
Getting Started with the Tool
We can install Postman either as a Chrome extension or as a native application. It's very easy to use and provides a collection of API calls, which one has to follow that collection of API calls for testing APIs.
One can select the API call method from the given dropdown list, set Authorisation, Header, Body information according to the API call.
API call methods available in Postman:
Header info according to the API Request
Body info according to the API Request
By, hitting on SEND button one can perform the API Request for the respective API CALL used.
Let us check Creating, Importing and Exporting Collections
A collection can be considered as a group of requests where one can add Each API call in the collection and create it, that can be reusable for an application. One can import a collection of others and can also export their collection so that can be used on other machines as well.
Creating a Collection
Importing a Collection
Exporting a Collection
Let us check now check Variables - Scope and initialization in Postman
These are defined as {{var_name}}
Scope -
- Environment aka Local Variables - Dependent on the Environment where the variables are defined.
- Global Variables - Not Dependent on any Environment Scope.
NOTE: When the same variable is defined in Local and Global, by default Global variable is STRIKED OFF and the Postman always takes preference of local variables.
Conclusion
Knowing how to test and debug APIs is a skill you must have on your skillset. Through my experience, API testing has enabled me to discover various errors and possible corrections when testing out solutions. I hope it helps you too!