You are on page 1of 3

NEWMAN TOOL – CLI COMPANION FOR POSTMAN TOOL

1) NEWMAN
a. CLI TOOL DEVELOPED FOR POSTMAN
b. USED TO GENERATE CLI REPORTS (CLI=Command Line Interface)
c. USED TO INTEGREATE API AUTOMATION WITH CI/CD TOOLS LIKE JENKINS, BAMBOO etc
d. USED TO GENERATE HTML REPORTS
e. FOR BETTER VISUALIZATION OF API TEST REPORTS
f. FOR EASE OF DEBUGGING & TROUBLESHOOTING API TESTS
g. FOR FASTER EXECUTION OF API TESTING

2) TO INSTALL NEWMAN, PRE-REQUISITES ARE


a. NODE JS  https://nodejs.org/en/download/
b. NPM
c. NEWMAN REPORTING PACKAGES

3) All HTML reports will be created in NEWMAN folder, mostly in C:\Users|<username> ; You can find this path
when you visit Start  Run  cmd  Press ‘ENTER_KEY’  Here, you will find the same path

4) INSTALL NODE JS FROM OFFICIAL WEBSITE https://nodejs.org/en/download/


a. THIS WILL INSTALL NODE JS AND NPM PACKAGES AUTOMATICALLY
b. Execute below commands to know if NodeJS is installed
i. node -v
c. Execute below commands to know if NPM is installed
i. npm -v

5) FOR UBUNTU OS, execute the following commands to install Node JS & NPM
i. sudo apt update
ii. sudo apt install nodejs
iii. sudo apt install npm

6) INSTALL NEWMAN USING


a. For Windows and Ubuntu users, the command is
i. npm install –g newman (g is for global installation on the local machine)
b. for Mac users, try homebrew installation on the Terminal
i. /bin/bash -c "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ii. brew install newman
c. for Ubuntu users, try the below
i. https://www.thelinuxfaq.com/npm/npm-packages/newman
OR
ii. login as root in ubuntu terminal and run the below cmd:
npm install -g newman

7) TO KNOW THE VERSION OF NEWMAN INSTALLED, RUN THE BELOW CMD:


a. newman -v

8) TO GET HELP COMMANDS OF NEWMAN, RUN THE BELOW CMD:


a. newman run -h

9) TO INSTALL HTMLEXTRA REPORTS USING NEWMAN, execute below command for html installation
npm install -g newman-reporter-htmlextra

10) WE CAN RUN THE BELOW NEWMAN COMMAND TO GENERATE HTML REPORT
a. newman run collection.json -r htmlextra
OR
b. newman run collectionPublicLinkURL -r htmlextra

11) WE CAN RUN THE BELOW NEWMAN COMMAND TO GENERATE JUNIT REPORT
a. newman run collection.json -r junit

12) WE CAN RUN THE BELOW NEWMAN COMMAND TO GENERATE JSON REPORT
a. newman run collection.json -r json
NEWMAN TOOL – CLI COMPANION FOR POSTMAN TOOL

Note:

 collection.json is the full path of the collection downloaded from Postman to your computer
 collectionPublicLinkURL is the public URL generated in Postman Collection by clicking on Share button

13) WE CAN RUN THE BELOW NEWMAN COMMAND TO GENERATE JSON/CLI REPORT
a. newman run collection.json
OR
newman run collection.json -r cli
OR
b. newman run collectionPublicLinkURL

14) WE CAN RUN NEWMAN COMMAND TO GENERATE CUSTOM PROJECT TITLE IN THE REPORT

newman run collection.json -r htmlextra --reporter-htmlextra-title "Project Name"


OR
newman run collectionPublicLinkURL -r htmlextra --reporter-htmlextra-title "Project Name"

15) To run a collection with multiple # of iterations (load testing), run the below commands:
a. newman run collection.json -n no.of iterations (use this command to generate CLI report)
b. newman run collection.json -n no.of iterations –r htmlextra (use this command to generate HTML
report)

Note: “no.of iterations”  write the number of iterations as per your requirement

16) To run a collection and environment,


a. newman run collection.json -e environmentName.json
OR
newman run collection.json -e environmentName.json -r htmlextra

newman run collection.json -e environmentName.json --bail newman

Note: environmentName.json is the full path of the environment file downloaded from Postman to your computer

17) To run a collection with data file (.CSV or .JSON),


The below commands are without environment parameter:

a. newman run collection.json -d fileName -n no.of iterations (to generate CLI report)
b. newman run collection.json –d fileName -n no.of iterations –r htmlextra (to generate HTML report)

Note: fileName is the full path of the data driven testing file (CSV or JSON) created on PC

The below commands are with environment parameter:

c. newman run collection.json -d fileName -n no.of iterations -e environment name (to generate CLI
report)
d. newman run collection.json -d fileName -n no.of iterations -e environment name –r htmlextra (to
generate HTML report)

18) To run a collection with one of its folder name [with or without environment parameter],

a. newman run collectionPublicLinkURL --folder “folderName” –r htmlextra [to execute 1 folder]


b. newman run collectionPublicLinkURL --folder “folderName” –folder “folderName” –r htmlextra [to
execute 2 folders]
c. newman run collection.json --folder “folderName” –r htmlextra
d. newman run collection.json --folder “folderName” -e environmentName.json -r htmlextra
e. newman run collection.json --folder “folderName” -e environmentName.json -r htmlextra --reporter-
htmlextra-title "Project Name"

19) To run a collection with delay time,


a. newman run collection.json –delay-request [delay time] -r htmlextra
b. newman run collection.json –timeout-request [timeout number] -r htmlextra
NEWMAN TOOL – CLI COMPANION FOR POSTMAN TOOL

c. newman run collection.json -delay delaytime (to generate CLI report with 1 iteration)
d. newman run collection.json -delay delaytime -n no.of iterations (to generate CLI report)
e. newman run collection.json -delay delaytime -n no.of iterations -r htmlextra (to generate HTML report)
f. newman run collection.json -n no.of iterations --delay-request [number] –r htmlextra (to generate
HTML report)

20) Show only Failures in HTMLExtra Report


a. newman run collection.json -r htmlextra --reporter-htmlextra-showOnlyFails
b. use –bail, to stop the execution when a test case fails
c. use –verbose, to show detailed execution run results

21) To execute Newman commands from Jenkins tool, follow below steps:
a. Install Jenkins on your computer
b. Ensure JDK v11 is installed on your computer
c. During installation of Jenkins, change Java Path to JDK v11 bin path in installation wizard
d. Launch Jenkins, after installation is completed
e. Create a new project & configure the windows batch command as below:
cd C:\Users\IQT\AppData\Roaming\npm\node_modules\newman\bin
newman run collectionPublicLinkURL -r htmlextra
f. Click on Apply & Save buttons
g. Run the build in Jenkins
h. Alternatively, refer this https://support.postman.com/hc/en-us/articles/360036847714-Running-a-
collection-through-Jenkins-

Note: IQT in the above path is the name of the logged in user on the computer ; replace it with your logged in user name
where newman is installed [this is the newman path]

To know more about HTMLExtra Reporting features,

https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/

https://www.npmjs.com/package/newman-reporter-htmlextra

You might also like