How to Run Collections using Collection Runner in Postman

How to Run Collections using Collection Runner

There are two ways to run a collection which is the Collection Runner and Newman. Let’s begin by executing the collection in Collection Runner.

Step 1) Click on the Runner button found at the top of the page next to the Import button.

Step 2) Collection Runner page should appear such as below. Following is the description of various fields

Step 3) Run your Postman Test Collection by setting up the following:

  • Choose Postman test collection- Set iterations as 3
  • Set delay as 2500 ms
  • Click on Run Postman Test… button

Step 4) Run Results page should be displayed after clicking the Run button. Depending on the delay, you should see the tests as they execute.

  1. Once tests have finished, you can see the test status if it is Passed or Failed and the results per iteration.
  2. You see Pass status for the Get Requests
  3. Since we did not have any tests for Post, there should be a message that the request did not have any tests.

You can see how important it is that there are tests in your requests so that you can verify HTTP request status if successful and the data is created or retrieved.

How to Run Collections using Newman

Another way to run a collection is via Newman. The main differences between Newman and Collection Runner are the following:

  1. Newman is an add-on for Postman. You will need to install it separately from the Native App.
  2. Newman uses the command line while Collection Runner has a GUI.
  3. Newman can be used for continuous integration.

To install Newman and run our collection from it, do the following:

Step 1) Install nodejs using this link: http://nodejs.org/download/

Step 2) Open the command line and enter

 npm install -g newman 

Newman should now be installed on your computer.

Step 3) Once Newman has been installed, let’s go back to our Postman workspace.In the Collections box, click on the three dots. Options should now appear. Select Export.

Step 4) Choose Export Collection as Collection v2.1 (Recommended) then click Export.

Step 5) Select your desired location then click Save. It is advisable to create a specific folder for your Postman tests. A collection should now be exported to your chosen local directory.

Step 6) We will also need to export our environment. Click on the eye icon beside the environment dropdown in Global, select Download as JSON. Select your desired location then click Save. It is advisable that the environment should be in the same folder as your collection.

Step 7) Environment should now be exported to the same local directory as Collection.

Step 8) Now go back to command line and change the directory to where you have saved the collection and environment.

 cd C:\Users\Asus\Desktop\Postman Tutorial

Step 9) Run your collection using this command:

 newman run PostmanTestCollection.postman_collection.json -e Testing.postman_globals.json

Run results should now appear such as below.

For guide is a reference to some basic Newman codes for execution:

  1. Run a collection only. This can be used if there is no environment or test data file dependency.
  2. Run a collection and environment. The -e indicator is for environment.
  3. Run a collection with desired no. of iterations.
  4. Run with data file.
  5. Set delay time. This is important as tests may fail if it is run without delay due to requests being started without the previous request completing processing on the endpoint server.
newman run <collection name> -d <delay time>

Summary

  • Postman is currently one of the most popular tools used in API testing
  • Accessibility, Use of Collections, Collaboration, Continuous Integration, are some of the Key features to learn in Postman
  • It’s recommended you create an account in Postman, so your collections are available online
  • You can parameterize request in Postman
  • You can create Tests to verify a postman request
  • Collections can be run using Newman or Collection Runner

About Author

Leave a Reply

Your email address will not be published. Required fields are marked *

PAGE TOP
error

Enjoy this blog? Please spread the word :)

RSS
Follow by Email