You have Newman installed. You have exported JSON files. Time to run. Open your terminal. One command. That is all it takes.
# The simplest Newman command
newman run collections/my-api-tests.postman_collection.jsonThat is it. Newman reads the JSON, fires every request in order, runs every test script, and prints results to the terminal. Let us understand what the output means.
newman
My API Tests
→ Get All Users
GET https://jsonplaceholder.typicode.com/users [200 OK, 5.67kB, 342ms]
✓ Status code is 200
✓ Response is an array
✓ Array has 10 users
→ Get Single User
GET https://jsonplaceholder.typicode.com/users/1 [200 OK, 1.2kB, 187ms]
✓ Status code is 200
✓ User has name field
✗ Email matches expected
AssertionError: expected 'Sincere@april.biz' to equal 'wrong@email.com'
┌─────────────────────────┬────────────────────┬───────────────────┐
│ │ executed │ failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ requests │ 2 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ test-scripts │ 2 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ asserts │ 5 │ 1 │
└─────────────────────────┴────────────────────┴───────────────────┘Green checkmark = test passed. Red cross = test failed. The summary table at the bottom gives you totals. In this example: 5 assertions executed, 1 failed.
| Exit Code | Meaning | CI/CD Impact |
|---|---|---|
| 0 | All tests passed, no errors | Build passes |
| 1 | At least one test/assertion failed | Build fails |
| 1 | Request error (timeout, DNS failure, etc.) | Build fails |
| 1 | Script error (JavaScript error in test/pre-req) | Build fails |
This is what makes Newman CI-friendly. You do not need any special integration. If Newman exits with 1, the CI pipeline step fails. Every CI tool — GitHub Actions, Jenkins, GitLab CI, CircleCI — understands exit codes natively.
# Run and check exit code
newman run collections/my-api-tests.postman_collection.json
# Check what happened
echo $?
# 0 = all good, 1 = something failedKey Point: Exit code 0 means every assertion passed. Exit code 1 means something went wrong. CI/CD tools use this to pass or fail your build. No extra configuration needed.
| Error | Cause | Fix |
|---|---|---|
| collection could not be loaded | Wrong file path | Check the path to your JSON file |
| getaddrinfo ENOTFOUND | Server unreachable | Check if the API server is running |
| Variable not resolved: {{baseUrl}} | No environment file provided | Add -e environment.json to the command |
| ETIMEDOUT | Request took too long | Add --timeout-request 10000 (10 seconds) |
| SyntaxError in test script | JavaScript error in Postman tests | Fix the script in Postman, re-export |
If tests pass in Postman but fail in Newman, the most common reason is missing environment variables. Postman uses your active environment automatically. Newman does not — you must specify it with the -e flag.
Q: Your Newman run passes locally but fails in CI. How do you debug?
A: Most common causes: 1) Missing environment file — Newman needs -e environment.json explicitly. 2) Secrets not available — CI does not have your Current Values, so pass them via --env-var "apiKey=$CI_SECRET". 3) Network differences — CI server may not reach internal URLs. 4) Timing — API might be slower in CI, add --timeout-request. 5) DNS — use full URLs, not localhost (CI runs on a different machine). Debug by adding -r cli with verbose output, and check the exact error in the summary table.
Key Point: newman run collection.json runs everything. Exit code 0 = all passed, 1 = failure. If tests pass in Postman but fail in Newman, you probably forgot the -e environment flag.