A Beginners Guide to Postman Features and Automation Scripts
What is Postman?
Postman is a great tool when trying to dissect RESTful APIs made by others or test ones you have made yourself. It offers a sleek user interface with which to make HTML requests, without the hassle of writing a bunch of code just to test an API’s functionality. Postman’s features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.
Advantages of postman!
1. Postman can be used as an API Client to quickly and easily send REST, SOAP and GraphQL requests directly.
2. We can automate manual tests and integrate them into your CI/CD pipeline to ensure that any code changes won’t break the API in production.
3. Mock an API by simulating endpoints and their responses without having to set up a backend server.
4. Generate and publish beautiful, machine-readable documentation to make your API easier to consume.
5. Stay up-to-date on the health of your API by checking performance and response times at scheduled intervals.
Automated Testing using Postman
1. Postman helps in automated testing by providing the feature to implement test cases for an API using javascript.
2. It also has the feature of Pre-request scripts to add any data or test case before the API hit.
3. We can define Environmental/Global/Collection specific variables in postman to help with automation.
4. Postman supports Chai assertions library. It provides functions and methods that help you compare the output of a certain test with its expected value.
5. Postman supports schema validation with the help of Tiny Validator.
6. A particular flow of tests can be run together with the help of Postman collection runner.
Designing and Mocking API
1. An example can be designed and mocked.
2. Example is the term used for a sandbox API in postman.
3. Once it is mocked, postman creates a mock server URL to be used for hitting the API defined in the example.
Monitoring using Postman!
1. We can monitor the APIs for uptime, responsiveness, and correctness.
2. We can define a monitor for an API collection along with monitor run frequency.
3. Receive mail notifications for run failures and errors.
4. Add delays, request timeouts and retry mechanisms for the monitor.
API Documentation using Postman
1. We can create beautiful web-viewable documentation from our collections.
2. Postman provides a public URL for accessing the collection.
Automation using Newman
1. Newman is a command line Collection Runner for Postman. It allows you to run and test a Postman Collection directly from the command line.
2. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
3. This can be integrated with Jenkins and be a part of the CICD process.
4. The automation script can run after the Continuous Deployment and a rollback can take place in case the Newman script execution fails for a particular build.
5. Detailed process for Jenkins and CICD integration: https://learning.postman.com/docs/running-collections/using-newman-cli/integration-with-jenkins/
Conclusion
As of now Postman is the most extensive API testing tool available in
the market. It has some out of the box features which have been discussed above in brief.
Happy API Testing!