Open In App

How do you run Postman collections using Newman CLI?

Last Updated : 19 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Postman is an API(application programming interface) development tool that helps to build, test and modify APIs.  In this tutorial, we will see how to run Postman collections using Newman CLI(Command Line Interface)

Prerequisites:

Step 1 : Checking of Node version

Newman is built on Node.js. To run Newman, make sure your system has Node JS installed. To check that open your command prompt and run the below command. If it returns the version as shown in the below image proceed to the further steps else Check here for installation.

node --version

ss_1-newman

Step 2: Installing Newman CLI

After successful installation of Node.js be on the same command prompt window and run the below command to install Newman CLI

npm install -g newman

Step 3: Export the collection from postman

After successful creation of collection in the Postman we need to download the collection to our local system to download at the side to your collection name press on three dots and click on export and a popup window appears and choose the collection according to your requirement and click on Export as shown below

ezgifcom-video-to-gif-converted-(3)

Step 4: Run the collection using Newman CLI

Now open your local terminal and run the below command

newman run <File_Path_here>

After the successful execution of the API request you will get the ouput screen as shown below it may vary based on your collection. note that you don’t use any environment variables.

ss-3_newman-(1)

Additional Step: If you have environment variables

Step 1: Follow the same above mentioned steps additionally you need to download the environment to your local system before exporting the environment make sure that variable value is in ‘initial value’ and click on three dots side to it and click on export as shown below and it will be downloaded successfully.

ezgifcom-video-to-gif-converted-(4)

Step 2: After that run the below command in your terminal to run the API request and you can see that the API request is successfully excecuted as shown below.

newman run <Collection_file_path_her> -e <environment_file_path_here>

ss-5_newman-final-(1)


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads