Postman - Newman Setup- To run postman collection in command line
1.Check for node js is available in your mac machine
node -v
npm -v
Note: Newman is node program. So, we need node to be installed for newman
If not available, install node js
2.Install newman
npm install -g newman
after installation
added 129 packages from 187 contributors in 22.438s
3. Export a postman collection in any folder
4.//terminal
Do change directory to the folder location
cd /Users/admin/Desktop/postman collection
5. //terminal
newman run name.postman_collection.json
Response will be like:
┌─────────────────────────┬─────────────────────┬─────────────────────┐
│ │ executed │ failed │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│ requests │ 7 │ 1 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│ test-scripts │ 5 │ 0 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│ prerequest-scripts │ 1 │ 0 │
├─────────────────────────┼─────────────────────┼─────────────────────┤
│ assertions │ 13 │ 0 │
├─────────────────────────┴─────────────────────┴─────────────────────┤
│ total run duration: 6.4s │
├─────────────────────────────────────────────────────────────────────┤
│ total data received: 11.49kB (approx) │
├─────────────────────────────────────────────────────────────────────┤
│ average response time: 1049ms [min: 184ms, max: 3.9s, s.d.: 1318ms] │
└─────────────────────────────────────────────────────────────────────┘
To add environment variable in newman
newman run prof.postman_collection.json --env-var domain="xxx"
In API request, Add {{domain}} for any base url/parameters. and use the above CLI
TIPS:
newman run -h
To check all options to be used with newman
Comments
Post a Comment