Building software often requires running many experiments. Some of these experiments can involve making HTTP requests to a backend. When developing a new API, I usually end up with a pretty comprehensive collection inside Postman, the tool I use to test APIs.
If you’re like me, your Postman collection can be something you forget about by the time you’re done building your API.
But what if we could make these Postman collections part of our build process? Well, we can. We can automate the running of these collections using Postman Newman.
To get started, you need to install Newman.
npm install -g newman
After getting Newman installed, running a collection is easy. Just export a collection from within Postman and then run it.
newman run tests.json
Running your collection will list the results of each run and include a summary.
You can configure the running of Newman to be part of your build pipeline. You can have these fail your build if any assertion fails.
This shouldn’t be a replacement for unit or integration tests. But Postman Newman API tests could be an excellent addition to your testing process.