Newman
Now that we have our Postman tests, complete in a collection with environments, we probably want to automate our tests. In Jenkins, this works pretty much the same as our Selenium tests; make sure your web service is running somewhere and run the tests using the command line. The problem is that Postman is a desktop application and we cannot run it from the command line. Not without Newman, that is (https://github.com/postmanlabs/newman). You can install Newman using npm
:
npm install newman --save-dev npm install newman -g
Before we can use Newman, we must do two things: export our collection and export our environment(s). We can start with the collection. Go to your collections in Postman and click the button with three dots. From the menu, choose Export
. You will now get a popup asking if you want to save as v1
or v2
; choose v2
(as recommended by the popup). I have saved the file in the web-api\tests
folder and I have chosen the name suggested by Postman, Web API.postman_collection...