Delivering More With Postman

Now that I’ve pushed the envelope with a mail delivery related title, I’ve no need to make any further puns. Instead, I can focus on addressing the issue at hand and stamping my authority on the topic.

Right, enough of that silliness – chances are you’ve been tasked with testing an API at some point in your distinguished careers as software testers. One of my favourite tools for doing so is the wonderful tool called Postman. One of the reason’s its so successful is it requires very little coding ability but it also affords you the flexibility to script tests if you wish – so it’s the ideal tool to use amongst a team of software engineers and more product facing engineers. A dirty little secret is I actually quite enjoy working with, shock-horror, “non-technical” people when it comes to Postman – if anything tools like this really help facilitate BDD and the writing of acceptance tests as Postman is so simple that anyone who has used a browser can get to grips with it.

However, this post is about doing more with Postman. So, I’m going to assume you have a neat little set of postman collections created and now you want to do more with them than just manually running them.

The creators of Postman have also created a lovely little accompanying tool titled Newman (which, I can only assume is named after Jerry Seinfeld’s nemesis in ‘Seinfeld’ – Kramer’s postman buddy by the name of Newman – I will try to confirm with the author). Newman is essentially a command line driver for any Postman collection and it is written in NodeJS so it is really rather easy to get started with.


Hello, Jerry.

So, you have a Postman collection, you want to use these as say part of an acceptance test run. For the sake of this article we will assume your API is built using some CI tool, like Bamboo or Jenkins, so now what? Now, we create an application in Node.

If you’ve never worked with Node before, it’s pretty simple to get going. On Linux or Mac OSX you can just download and install Node here. You will see references to a tool called npm throughout this post, npm is simply the package manager used within node.

You now have Node installed. Excellent! Let’s assume you have a Postman collection already you want to run. For this I’ll be using a collection I quickly put together to run against the FOAAS API. You can retrieve the collection here.

As an aside here, if you’re working in Windows, you can either follow the install instructions from here or work in a simulated Linux environment in Cygwin. It’s all good.

In your project folder, you’ll now need create a package file for your application and install newman.

npm init

The above will initiate the creation of a package file for your app – this file contains all the information you need to run the app including any dependencies. You can answer the questions it provides in relation to your project – you should take a look here for more information, though.

npm install newman –save

The “–save” tag will install Newman but also add it into the package.json file as a dependency, this way when anyone else downloads your app, all they will need to do to get all the dependencies is to type ‘npm install’.

Good stuff, we now have our package.json created and installed Newman. We can at this stage actually just kick off the collection with:

newman -c shakespearian_insult.json (or path to your collection)

You should now start to see some results coming in – congratulations, you’re now running your Postman collections via a command line tool.

The next step is even simpler, all you need to do is to have a CI task repeat the above steps (or pull down an application you’re building and have put in some code repository that makes use of npm – I smell a future tutorial on this!) – so, for example, let’s say you’re using Jenkins.

You can either install Newman globally onto your Jenkins box by ensuring it has NodeJS as above and entering:

npm install -g newman

The -g flag will install Newman globally so it doesn’t need tied to any package.json to run, instead you can run from anywhere. Alternatively, you can have your CI job not depend on any preconditions for the Jenkins box and marshall it’s own requirements (my preference) by repeating the steps above in a Jenkins ‘Execute Shell‘ build component (or something similar in whatever your CI tool is).

It really is that simple. One of the nice things about Newman is it is open source and available as a library, so you can import it into your own NodeJS application and work from there, or just use it as a command line tool as above.

This has been a fairly ‘scratching the surface’ overview of how you can do more with your Postman collections, but there’s absolutely no reason why you can’t treat them in the same way as you’d treat any other automated tests. I’ll definitely look at doing a more indepth tutorial with these technologies at a later date and have a proper sample project for you to look at.

For now, have fun automating your Postman collections!

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar

About Me

About Me

Hi. I'm Neill. I'm a software tester from Belfast. You could say a Belfast Tester. I've worked in some companies and all my thoughts are my own. Not the man's. I can think for myself. Honestly.

Latest Posts

Social Profiles