Open In App

How to Run Postman Collections from Command Line using Newman?

Improve
Improve
Like Article
Like
Save
Share
Report

Newman is a command-line Collection Runner for Postman. It enables you to run and test a Postman Collection directly from the command line. It’s built with extensibility in mind so that you can integrate it with your continuous integration servers and build systems. Newman maintains feature parity with Postman and allows you to run collections the way they’re executed inside the collection runner in Postman. 

Postman is one of the most widely used applications for API testing, which provides testing for various types of HTTP requests like GET, POST, PUT and DELETE. Also, the postman provides automation testing by performing tests in several iterations using Newman or collection runner. In this article, we are going to discuss how to run the Postman collections from the command line.

Note: For creating Collection in postman refer to this article: How to Add Test Validation in Postman and Performing Get Request?

Pre-requisites:

  1. Install Node.js
  2. Install Newman
  3. Export collection and run from cmd.

Install Node.js:

To install the Newman we needed the node.js. So first check your system has a node package by running the command “node -v” if your system does not have the node.js install it https://nodejs.org/en/download/. Install the node.js according to your system configuration.

 

Install Newman:

After installing the node.js, now install the Newman package.

npm install -g newman

 

Export the Collection from Postman:

Export the collection that you want to run in the command line, from the postman. Click on the collection and select Export on the selected folder.

 

Run from Command Line

  • Now navigate to the exported folder and open cmd.
  • Enter the command “newman run file_name”

Note: Here the collection is “FirstTest.postman_collection.json” so we have entered the command “newman run FirstTest.postman_collection.json” to run the collection

  • After entering the command we will get the results.

 


Last Updated : 24 May, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads