
Run Your Postman Collection with Newman
Methods to Run Postman Collection on Command Line Using Newman
Postman collections can be executed via the command line using Newman, a command-line collection runner for Postman. This can be possible if you have Nodejs and Newman installed. Below are three easy-to-follow methods with illustrations and key steps.
1st Method: Exported Postman Collection
Steps:
1. Create your Postman collection with test script
2. Export the collection into a file
3. Open command line
4. Copy the path where the collection is located (Find the file right-click on it and select “copy as path”).
5. Return to the command line and type the command: newman run and add the path.
6. Remember to edit the path by removing duplicates like: “C:\Users\Iziren John\” from the path“ before running it.
For this approach, the next time the collection API request changes, you must repeat the process by exporting the collection again.
2nd Method: JSON Link
Best Practice for Reusable Collections
1. Right Click on your Postman collection
2. Select the share option
3. Select “via a JSON link”
4. Copy the link that is generated for you
[Note: when there is a change in the collection request, you will have to select the update button link to copy the updated version]
5. Go to the command line and run the command: newman run
3rd Method: Postman CLI Option
When the Share Option Is Unavailable
1. Right Click on your Postman collection
2. Select the Run Collection Option
3. Scroll down to “Run on Postman CLI”
4. Copy the link that is generated for you
[Note: when there is a change in the collection request, you will have to select the update button link to copy the updated version]
Go to the command line and run the command: newman run
Summary Table
You can choose the method that works best for your workflow. Each ensures the smooth execution of Postman collections through Newman!