Newman is a command-line runner for postman collections. In other words, it allows a user to run an existing postman collection through the command line.
It expects or consumes the JSON version of the collection that can be obtained by simply exporting the collection in JSON collection format or the URL of the collection which is nothing but the same JSON that’s obtained by the collection export.
node -v
v16.13.0
To download and install node for Mac OS: https://nodejs.org/en/download/
newman -v
5.3.2
To download and install newman on Mac OS by CLI:
npm install -g newman
The command used to run the Postman collection using Newman is:
newman run {{collectionJsonPath}}
OR
newman run {{collectionUrl}}
To run postman collection in json format using newman command:
newman run e2e.postman_collection.json
To run postman collection with environment variables using newman command:
newman run e2e.postman_collection.json -e e2e.postman_environment.json
Newman html reporter is again a node module and has to be separately installed using the below command:
sudo npm install -g newman-reporter-html
sudo npm --force i -g newman-reporter-html (to override if already exists)
Upgrade node to latest version(not recommended as npm is out of funds):
sudo npm install -g npm@9.1.1
Newman html report will be generated under newman folder of executed postman collection.json path:
newman run e2e.postman_collection.json -e e2e.postman_environment.json -r html
Sample report generated path: file:///Users/praveen.kumar/Desktop/postman%20newman/newman/newman-run-report-2022-11-11-06-43-45-523-0.html
Note:
-> my json files are in Desktop path('postman newman' folder)
->https://www.geeksforgeeks.org/how-to-generate-html-report-for-postman-collection-using-newman/
-> reference: https://www.softwaretestinghelp.com/postman-newman/
-> https://learning.postman.com/docs/running-collections/using-newman-cli/installing-running-newman/
-> https://www.npmjs.com/package/newman-reporter-htmlextra
No comments:
Post a Comment