Newman is asked about in almost every API testing interview. Interviewers want to know if you have actually used it in a real project or just read about it. These questions go beyond "what is Newman" — they test your hands-on experience with CI/CD, reporting, and troubleshooting.
Q: What is Newman? How is it different from Postman?
A: Newman is the command-line collection runner for Postman. Postman is a GUI tool where you build, debug, and manually run API tests. Newman runs those same tests from the terminal without any GUI. The main difference is automation — Newman can run in CI/CD pipelines, cron jobs, and Docker containers. It reads the same collection JSON files that Postman exports. Tests pass in Postman should pass identically in Newman. Think of Postman as the design studio and Newman as the factory line.
Q: How do you run a Postman collection using Newman?
A: Export the collection from Postman as JSON (Collection v2.1 format). Install Newman via npm (npm install -g newman). Run: newman run collection.json. To include an environment: newman run collection.json -e environment.json. To inject secrets: newman run collection.json --env-var "apiKey=secret123". To generate reports: add -r htmlextra --reporter-htmlextra-export report.html. Exit code 0 means all tests passed, 1 means something failed.
Q: How do you handle secrets in Newman for CI/CD?
A: Never put secrets in environment JSON files that get committed to git. Use --env-var flag to inject secrets at runtime from CI/CD secret stores: newman run collection.json --env-var "apiKey=${{ secrets.API_KEY }}". In GitHub Actions, secrets are stored in repository Settings > Secrets. In Jenkins, use credential bindings. The environment JSON file should only have non-sensitive Initial Values. Current Values are not exported, so secrets never leave the developer machine.
Q: What Newman reporters have you used? How do you generate reports?
A: CLI reporter for terminal output during development. htmlextra (newman-reporter-htmlextra) for beautiful HTML reports that I share with the team and stakeholders — it shows request/response details, charts, and failure highlights. JUnit for CI/CD integration — Jenkins and GitLab CI parse JUnit XML to show test results in their dashboards. I use multiple reporters at once: -r cli,htmlextra,junit with separate export paths for each. The if:always() pattern in CI ensures reports are uploaded even when tests fail.
Q: Your Newman tests pass locally but fail in CI. How do you troubleshoot?
A: Five things I check: 1) Environment variables — did I forget -e flag or --env-var for secrets? 2) Network — CI server may not reach internal APIs (use full URLs, not localhost). 3) Timing — APIs may be slower in CI, add --timeout-request. 4) Dependencies — is the API server deployed before tests run? Use needs/depends_on in CI config. 5) Version mismatch — pin Newman version in package.json devDependencies to match local. I also add verbose logging and check the JUnit/HTML report artifacts for exact error messages.
Q: How do you run data-driven tests with Newman?
A: Use the -d flag with a CSV or JSON file: newman run collection.json -d test-data.csv. Each row becomes one iteration. Column headers become variables accessible via {{columnName}} in requests and pm.iterationData.get("columnName") in scripts. I include both positive and negative test cases in the data file. Use CSV for flat data and JSON for nested structures. You can limit iterations with -n flag. I always include a "testCase" description column so the report shows human-readable names per iteration.
Q: Can you run Newman programmatically? When would you do that?
A: Yes, Newman is also a Node.js library. Install it (npm install newman), then use newman.run() in your JavaScript code. Use cases: 1) Running multiple collections in sequence and aggregating results. 2) Custom reporters — listen to events like beforeRequest, assertion, done. 3) Dynamic configuration — choose collection based on branch name or deployment target. 4) Integration with Mocha/Jest — wrap Newman runs inside test suites. 5) Custom notifications — send Slack messages on specific failures. The callback receives a summary object with all statistics and failure details.
| Question | Short Answer |
|---|---|
| What is the exit code when Newman tests fail? | 1 |
| How to skip SSL verification? | -k or --insecure flag |
| How to run only one folder? | --folder "Folder Name" |
| How to stop on first failure? | --bail flag |
| How to add delay between requests? | --delay-request 1000 (in ms) |
| How to inject secrets in CI? | --env-var "key=$SECRET" |
| How to run N iterations without data file? | -n 10 |
| Which report format for Jenkins? | JUnit XML (-r junit) |
| How to install Newman for a team project? | npm install --save-dev newman |
| Can Newman use Postman's Collection Runner? | No. Newman is the CLI equivalent. |
Key Point: Newman interview questions test real-world CI/CD experience. Know exit codes, environment handling, reporting, data-driven runs, and troubleshooting CI failures.
Answer all 5 questions, then submit to see your score.
1. What exit code does Newman return when all tests pass?
2. How do you inject a secret API key into Newman in a CI/CD pipeline?
3. Which Newman flag stops the entire run on the first test failure?
4. What is the purpose of the newman-reporter-htmlextra package?
5. Which command runs a Newman collection with a CSV data file?