Postman is a tool that permits the user to create, use and test Rest APIs. It is accessible as a Chrome extension. Postman permits the user to create collections of integration tests to guarantee that an API is working as expected. For each test, an HTTP request is made and test assertions will be written in JavaScript and then used to check the quality of code.Postman also permits the user to store information from past tests into global variables. These variables can be utilized precisely like environment variables. For instance, there is an API that requires information received from another API. Users can store the response (or part of the response, since it is JavaScript) and utilize that as part of a request header, post body, or URL for the resulting API calls.
The following features have helped Postman become an effective tool of choice:
Distinguish the environment that you need to define. Variable names are wrapped with double curly braces{{ }}. For example, {{loginurl}}.You’ll see the environment variables in the endpoint URL and Headers territories of the Postman Collection.Below are the steps:
Step 1: Click on the Environment button(eye button) in the upper right of Postman and click Add on Top right corner.
Step2: Add VARIABLE, INITIAL VALUE and click the Add button.
Step 1: To Run the Postman collection export collection in json format.
Step 2: Open Terminal, then navigate to the exported Postman file location and run the below command.
Command: $ newman run <collection-file-source> -e <environment-file-source> -r report.htmlStep 3: After successfully executing the command, an HTML report will be generated in the same directory.
Step 4: Open the generated file with Chrome or Firefox browser.
Postman's versatility in organizing collections, utilizing environments, and employing script-based validations makes it a powerful tool for API testing across various server environments. Leveraging environment variables enables efficient management of URL changes, reducing time spent on updates across numerous requests. Newman's integration allows for command-line execution, automation, and comprehensive report generation, solidifying Postman's role in ensuring reliable API testing within modern software development workflows