Postman is great for building and debugging. But you cannot open Postman in CI/CD. You cannot schedule Postman to run at 6 AM every day. That is where Newman comes in. Newman is the command-line runner for Postman collections.
# Install Newman globally
npm install -g newman
# Install HTML reporter for pretty reports
npm install -g newman-reporter-htmlextra
# Verify installation
newman --versionOpen your ReqRes.in collection in Postman
Click the three dots (...) next to the collection name
Select Export > Collection v2.1 > Export
Save as ReqRes-Full-Suite.postman_collection.json
Go to Environments > ReqRes Dev > Export
Save as reqres-dev.postman_environment.json
# Run collection with environment
newman run ReqRes-Full-Suite.postman_collection.json \
-e reqres-dev.postman_environment.json
# Run with HTML report
newman run ReqRes-Full-Suite.postman_collection.json \
-e reqres-dev.postman_environment.json \
-r cli,htmlextra \
--reporter-htmlextra-export reports/reqres-report.html \
--reporter-htmlextra-title "ReqRes.in API Test Report" \
--reporter-htmlextra-browserTitle "API Tests"Newman can iterate your collection with different data from a CSV file. Create a users CSV and use {{column_name}} in your request body.
name,job,expectedStatus
Rahul Sharma,QA Engineer,201
Priya Patel,SDET,201
Amit Kumar,Dev Lead,201
Neha Gupta,Test Architect,201
Vikram Singh,QA Manager,201Update your Create User request body to use CSV variables:
{
"name": "{{name}}",
"job": "{{job}}"
}const response = pm.response.json();
const expectedStatus = parseInt(pm.iterationData.get("expectedStatus"));
pm.test("Status matches expected: " + expectedStatus, function() {
pm.response.to.have.status(expectedStatus);
});
pm.test("Name matches CSV data", function() {
pm.expect(response.name).to.eql(pm.iterationData.get("name"));
});
pm.test("Job matches CSV data", function() {
pm.expect(response.job).to.eql(pm.iterationData.get("job"));
});# Run with CSV data file — collection runs 5 times (once per row)
newman run ReqRes-Full-Suite.postman_collection.json \
-e reqres-dev.postman_environment.json \
-d test-users.csv \
-r cli,htmlextra \
--reporter-htmlextra-export reports/data-driven-report.html \
--reporter-htmlextra-title "Data-Driven API Test Report"
# Run specific folder only
newman run ReqRes-Full-Suite.postman_collection.json \
-e reqres-dev.postman_environment.json \
--folder "Users — CRUD" \
-r cli┌─────────────────────────┬──────────┬──────────┐
│ │ executed │ failed │
├─────────────────────────┼──────────┼──────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ requests │ 18 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ test-scripts │ 18 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ prerequest-scripts │ 2 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ assertions │ 54 │ 0 │
├─────────────────────────┼──────────┼──────────┤
│ total run duration: 12.4s │
├─────────────────────────┼──────────┼──────────┤
│ average response time: 387ms │
└─────────────────────────┴──────────┴──────────┘The htmlextra reporter creates a beautiful interactive report. It shows every request with response body, headers, test results, and timing. Open reports/reqres-report.html in a browser. This is what you share with managers and stakeholders.
When running data-driven tests, Newman runs the ENTIRE collection once per CSV row, not just the request that uses the data. If you only want to iterate the Create User request, move it to a separate collection or use the --folder flag to run specific folders.
Q: How do you run Postman collections in CI/CD?
A: We use Newman, the CLI runner for Postman. The collection and environment JSON files are exported from Postman and stored in the Git repository. In CI, we install Newman via npm, then run the collection with environment variables and the htmlextra reporter. For data-driven testing, we use the -d flag with a CSV file — Newman iterates the collection once per row. Reports are generated as HTML and uploaded as build artifacts. We can also run specific folders using the --folder flag for targeted testing. The exit code from Newman tells CI whether tests passed or failed.
Key Point: Newman runs Postman collections from CLI — perfect for CI/CD. Use htmlextra for HTML reports and -d flag for data-driven runs with CSV files. Store collection and environment JSONs in Git.