You have read about Newman. Now you use it. These exercises go from beginner to CI/CD. Do them in order. By the end, you will have a fully automated API test pipeline running from the command line.
Install Newman globally: npm install -g newman
Verify: newman --version
In Postman, create a simple collection with 2-3 GET requests to https://jsonplaceholder.typicode.com (e.g., /users, /posts/1, /todos?userId=1)
Add at least one pm.test() assertion to each request
Export the collection as v2.1 JSON
Run it: newman run your-collection.json
Read the output — check the summary table at the bottom
Check the exit code: echo $?
Create two environments in Postman — "Dev" with baseUrl = https://jsonplaceholder.typicode.com and "ReqRes" with baseUrl = https://reqres.in/api. Update your collection to use {{baseUrl}} in all requests. Export both environments. Run Newman with each:
# Run with Dev environment
newman run collection.json -e dev.json
# Run with ReqRes environment
newman run collection.json -e reqres.json
# Both should run — responses will differ but structure worksInstall the htmlextra reporter. Run your collection and generate an HTML report. Open it in your browser. Explore the report — look at request/response details, failed tests, timing charts.
npm install -g newman-reporter-htmlextra
newman run collection.json \
-e dev.json \
-r htmlextra \
--reporter-htmlextra-export report.html
open report.htmlCreate a CSV file with 5 user IDs (1-5). Create a GET request to {{baseUrl}}/users/{{userId}} with assertions. Run Newman with the data file. Check that all 5 iterations pass.
userId,expectedName
1,Leanne Graham
2,Ervin Howell
3,Clementine Bauch
4,Patricia Lebsack
5,Chelsey Dietrichnewman run collection.json \
-e dev.json \
-d exercise4-data.csv \
-r cli,htmlextra \
--reporter-htmlextra-export data-driven-report.htmlCreate a project with package.json. Install Newman locally. Add npm scripts for test:dev, test:staging, and test:ci. Run each one. This simulates what happens in a real CI/CD pipeline.
# Initialize project
mkdir api-tests && cd api-tests
npm init -y
npm install --save-dev newman newman-reporter-htmlextra
# Copy your collection, environment, and data files into the project
mkdir collections environments data reports
# Add scripts to package.json (edit manually)
# Then run:
npx newman run collections/your-collection.json -e environments/dev.jsonTry each of these flags with your collection and observe the difference:
After completing all 6 exercises, you have done everything a QA engineer does with Newman in a real project. Export, run, report, data-drive, CI-integrate. That is the full workflow. Now practice until the commands come from muscle memory.
Key Point: Do all 6 exercises: install and run, environments, HTML reports, data-driven runs, npm scripts, and advanced flags. These cover the real-world Newman workflow end to end.