API Testing Using Postman and Newman
In the last few years, we have an exponential increase in the development and use of APIs. We are in the era of API-first companies like Stripe, Twilio, Mailgun etc. where the entire product or service is exposed via REST APIs. Web applications also today are powered by REST-based Web Services. APIs today encapsulate critical business logic with high SLAs. Hence it is important to test APIs as part of the continuous integration process to reduce errors, improve predictability and catch nasty bugs.
Postman comes with a nifty CLI tool — Newman. Newman is the Postman’s Collection Runner engine that sends API requests, receives the response and then runs your tests against the response. Newman lets developments easily integrate Postman into continuous integration systems like Jenkins. Some of the important features of Postman & Newman include:-
- Ability to test any API and see the response instantly.
- Ability to create test suites or collections using a collection of API endpoints.
- Ability to collaborate with team members on these collections.
- Ability to easily export/import collections as JSON files.
We are going to look at all these features, some are intuitive and some not so much unless you’ve been using Postman for a while.
Setting up Your Postman
Later, can then look it up in your installed apps and open it. You can choose to Sign Up & create an account if you want, this is important especially for saving your API collections and accessing them anytime on any machine. However, for this article, we can skip this. There’s a button for that towards the bottom when you first launch the app.