The Collection Runner runs a collection or folder sequentially, and a data-driven run attaches a CSV or JSON file where one row equals one iteration. File columns become data-scope variables, so the iteration count equals the row count and new boundary or negative values are added as a row without script changes. A value in quotes arrives as a string, so comparing it with a status needs Number(...).
API · Runner, data-driven tests and Newman
One request must run against five data sets. Do you copy it five times?
A transfer needs five amounts checked: a normal one, zero, negative, too large and a currency that does not exist. The easiest way is five copies of the request with different bodies. A month later a header is fixed in two copies and not in three, and a new boundary needs a sixth copy. The Collection Runner works differently: one request and the data apart.
How it works and why it is designed so
The Collection Runner runs a whole collection or folder sequentially: with the chosen environment, the number of iterations and a delay between requests. The outcome looks like a pass/fail table for each pm.test. For a data-driven run you attach a CSV or JSON file: one row is one iteration and the columns become variables of the data scope. The number of iterations then equals the number of rows and the whole set of requests runs for each row. This separates behaviour from data: new boundaries are added as a row in the file without changing scripts.
One request, many data rows
Figure 1. A new boundary is added as a row in the file: the request and the script stay the same.
Example: five cases from one request
The data file: the input, the currency and the expected status in one row.
And the check reads the same row through pm.iterationData. Number(...) is needed because values from a file should not be assumed to be numbers: comparing the status with the string '201' will not pass:
// Post-response of POST {{baseUrl}}/transfersconst amount = pm.iterationData.get('amount');
const expected = Number(pm.iterationData.get('expectedStatus'));
// the iteration value in the name: the report shows which row failed
pm.test('amount=' + amount + ' -> ' + expected, () => {
pm.response.to.have.status(expected);
});
The test name contains the iteration value, so the report shows exactly which row failed. Without it five identical "Status is 201" explain nothing. How to work with JSON files, types and clean data between iterations is covered in the lesson on data-driven in depth.
Limits and alternatives
The Runner is handy for manual and semi-manual runs, but it runs from Postman. For CI the same run is done by Newman or the Postman CLI (see the lesson on Newman). A file row sets only values: complex logic ("for role A expect 403, for B 200") is better encoded in an expected-result column than in script branches. When there are hundreds of cases and generators are needed, code with parameterised tests is easier to maintain (the lesson on Postman's limits).
Common mistakes
Identical test names. The report has five "Status is 201" and it is unclear which row failed;
Comparing with a type that is not there. A quoted value ("201") arrives as a string, and to.have.status compares a string with the status text (Created), not the code: convert through Number;
A file column matches an environment variable name. The data scope is narrower and silently overrides the environment;
Data that depends on row order. Row 2 relies on what row 1 created. Iterations must be independent;
A file with empty rows, an uneven column count or Windows line endings. Column names or the iteration count may differ from what you expect: compare them with the report of the first run.
Check yourself
A CSV has six data rows. How many iterations does the Runner perform and how many times does each request of the folder run?
Answer
Six iterations, and each request of the folder runs once per iteration, that is six times. The file columns are available as data-scope variables only within their own iteration.
The CSV holds the status in quotes ("201") and the test pm.response.to.have.status(pm.iterationData.get('expectedStatus')) fails although the status is right. Why?
Answer
A quoted value arrives as a string, and status() compares a string with the status text, not the code (Newman converts only unquoted numbers itself). Use Number(...) (in a JSON file the number would stay a number). The test name is worth composing from the row values so the cause is visible.
Related lessons: “Data-driven in depth: files, iterations, data isolation”, “Newman and CI”, “Variable scopes and secrets”.
In an interview.Junior: The Collection Runner runs a collection with an environment and iterations. For data-driven runs I attach a CSV or JSON where each row is an iteration with input data and an expected status, and so I cover boundary and negative values. Middle/Senior: I separate behaviour from data: one request and one check, while boundaries and negative cases live in a table. I name the test with the row values, keep iterations independent and run the same thing through Newman for CI.
Newman and CI
Newman runs the same Postman collection from the command line without a UI and exits with a code that any CI understands. The code is zero when everything passed and non-zero when a test failed or a runtime error occurred, so the pipeline step turns red with no extra setup. Secrets are passed with --env-var from the CI secret store, and the report is kept as an artifact.
API · Runner, data-driven tests and Newman
The collection is green in Postman but no pipeline runs it. How do you hook it into CI?
A collection is written in Postman, run by hand before a release, and that is how it lives. API regression stays the job of one person with an open app, and the pipeline knows nothing about it. Newman fixes that: the same collection file runs from the command line without a UI, and the result becomes an exit code that any CI understands.
How it works and why it is designed so
Newman is a CLI runner of collections. The collection and the environment are exported to JSON and put into the repository (or taken from the same branch as the code). Newman runs requests and scripts by the same rules as the Runner and then exits with a code: zero if everything passed and non-zero if at least one test failed or an execution error happened. CI does not read the log: it looks at the exit code, so the step turns red with no extra setup.
From Newman to a red CI step
Figure 1. CI does not read the log, it looks at the exit code, so it must not be suppressed.
Example: from a manual run to a pipeline step
Before: the collection is run by hand before a release and nobody keeps a report. After: one command in the pipeline with an environment, data and three reporters:
npm i -g newman@6 newman-reporter-htmlextra@1
newman run bank-api.postman_collection.json \
-e stage.postman_environment.json \
-d transfers.csv \
--env-var "password=$API_PASSWORD" \
-r cli,htmlextra,junit
The cli reporter writes a log for humans. junit creates a machine report that Jenkins, GitLab and GitHub tooling show as separate tests. htmlextra (a separate package) gives HTML with raw requests and responses: when something fails overnight you see what was sent and received without a rerun. The report is worth keeping as a job artifact. The failure summary looks roughly like this:
# a simplified result (not a verbatim log)
POST /transfers - 201 created [OK]
POST /transfers - 422 amount 0 [FAILED]
assertions: 12 total, 11 passed, 1 failed
exit code: 1
Secrets are passed through --env-var from the CI secret store and are not kept in the environment file that sits in git. Postman offers one more path of its own, the Postman CLI (postman collection run); flags, reports and a comparison of the two tools are covered in the lesson on Newman in CI.
Limits and alternatives
Newman reproduces the Runner, not the whole app. It has no Postman Vault and cannot see your laptop's local values: everything needed must come from the environment file or --env-var. It is updated more slowly than the app, so the newest script features may not work there: check the collection on the Newman version that sits in CI. For a large regression set with logic and review in git the same job is more convenient in code (the lesson on Postman's limits).
Common mistakes
A secret in the environment file in the repository. Pass it through --env-var from the CI store;
Not keeping the report. A night failure without an HTML report has to be reproduced;
Not pinning versions. A new Newman or reporter release breaks the pipeline with no change in the collection;
Running unsafe requests against production. CI needs a separate environment with test data.
Check yourself
How does CI learn that a test in the collection failed, if Newman returns nothing but a log?
Answer
From the exit code: Newman exits with a non-zero code when a test fails or an execution error occurs, and the step turns red. The log is not needed for that.
Why is the password passed through --env-var instead of written into the environment file?
Answer
The environment file sits in git, so the password would reach the history. --env-var takes the value from the CI secret store at run time and leaves nothing in the repository.
Related lessons: “Collection Runner and data-driven tests”, “Newman in CI: flags, reports, exit codes, Postman CLI”, “Secrets, mock servers and monitors in Postman”.
In an interview.Junior: In CI I run the collection through newman run with an exported environment and a JUnit reporter, and pass secrets through --env-var. A failed test gives a non-zero exit code and the pipeline turns red. Middle/Senior: I keep the HTML report as an artifact, pin the Newman and reporter versions and keep a separate CI environment with test data. I remember that Newman has no Vault and lags behind the app, so I verify the collection on the pipeline's version.
Postman's limits
Postman suits exploring an API and quick checks, while a large regression suite with logic and git review is better kept in code. A new endpoint is explored in Postman and stable scenarios move into automated tests, but a small suite run in CI through the Postman CLI need not be moved on principle. Newman gets no updates and stays only in older pipelines.
API · Runner, data-driven tests and Newman
A collection has grown to a hundred requests and its JSON diff is unreadable. What now?
A collection started with ten requests and now has a hundred, with scripts that copy one another. A pull request shows a thousand-line JSON diff in which you cannot see what changed. Someone asks whether to move it to code. The answer is not "Postman is bad" but "each tool has its job": this lesson is about where the line is.
How it works and why it is designed so
Postman is built for working with an API by hand: send a request, look at the response, save an example, share with the team. That is why it is strong at exploring a new endpoint, quick checks and shared documentation with developers. Code is built for maintaining logic over time: functions, types, review, reuse. A regression set with logic, data factories and review in git is easier to maintain in code: Playwright request, Cypress cy.request, RestAssured.
Postman or code
Postman
Exploring and quick checks
A new endpoint, a manual run, shared documentation with developers, a mock and a monitor.
Code
Regression suite
Logic, data factories, review in git, one CI and reporting together with UI tests.
Figure 1. Both tools are legitimate, they answer different questions.
The reasons regression is moved to code:
An exported collection in JSON reads poorly in a diff (the newer Postman format with separate YAML files per request improves this), and reviewing script changes is awkward;
Logic is harder to reuse: helpers, test data factories, shared fixtures;
In code API tests live next to UI tests, with the same CI, reporting and types;
In TypeScript API tests types generated from OpenAPI show at compile time which tests a schema change touched, and schema validation at run time catches a mismatch with the real response.
Example: the same case in two places
The check in Postman looks like this:
// Postman: post-response of POST /transfers
pm.test('Transfer created', () => {
pm.response.to.have.status(201);
pm.expect(pm.response.json().amount).to.eql(150);
});
And here it is in code. The difference is not the request but that the test is now an ordinary file: it shows in a diff, can be parameterised, can use an extracted helper, run next to UI tests and be typed.
// Playwright: the same case in code, baseURL in the configimport { test, expect } from'@playwright/test';
test('POST /transfers creates a transfer', async ({ request }) => {
const res = await request.post('/transfers', {
data: { amount: 150, currency: 'UAH' },
});
expect(res.status()).toBe(201);
expect((await res.json()).amount).toBe(150);
});
When to choose which
The table sums up the difference by the criteria that drive the choice:
Postman
Code
Start
A request in minutes
Needs a project and config
Scripts
JavaScript in pm.*
Project language, types
Review
Diff of collection JSON or YAML
Code diff
Logic reuse
Collection scripts, Package Library
Functions, modules, fixtures
CI
Postman CLI (Newman gets no updates)
The same pipeline as UI
Who maintains
Manual and automation QA
People who write code
Postman: a new endpoint, a manual run, shared documentation with developers, a mock and a monitor, a small set where nobody reviews scripts;
Code (Playwright request, RestAssured): a regression suite with logic and data factories, review in git, one CI with UI tests. RestAssured fits when the team's automation is in Java, Playwright request or cy.request when it is in JS/TS and UI tests already sit beside it.
Limits and alternatives
This is not an either-or choice. A workflow that has proven itself: a new endpoint is explored in Postman first (importing OpenAPI saves time at the start) and stable scenarios are moved into automated tests. Postman stays for documentation, a mock server, a monitor and quick manual checks. If the team is small, the set is small and nobody reviews scripts, a collection that CI runs through the Postman CLI is quite enough: migrating on principle is not worth it. Postman no longer updates Newman and recommends replacing it with the Postman CLI, so Newman stays only in older pipelines.
Common mistakes
Moving everything to code without a reason. You lose exploration speed and the gain is small for a small set;
Keeping regression in a collection with dozens of script helpers. Logic is copied and review is impossible;
Duplicating the same case in both Postman and code. A month later they diverge and nobody knows which to trust;
Dismissing Postman outright. For documentation and manual checks it is often more efficient.
Check yourself
Name two reasons a large API regression set is moved from a Postman collection to code.
Answer
Review in git (the collection JSON reads poorly in a diff) and reuse of logic (helpers, data factories). Also: a single CI with UI tests and types from OpenAPI that show the effects of schema changes.
What is Postman still useful for even when regression is in code?
Answer
For exploring new endpoints, quick manual checks, shared documentation with developers, and a mock server and a monitor.
Related lessons: “Swagger/OpenAPI in testing”, “Collection structure: folders, inheritance, documentation”, “API testing in Playwright”, “APIRequestContext in depth”, “Newman in CI: flags, reports, exit codes, Postman CLI”.
In an interview.Junior: Postman is for exploration and quick checks, while I keep a large regression set in code, for example on Playwright request, next to UI tests and with review in git. That makes logic easier to reuse and tests easier to maintain. Middle/Senior: The decision depends on team size and make-up: I explore a new endpoint in Postman, move stable scenarios to code and leave documentation and the mock in Postman. I would not migrate a small set that runs in CI through the Postman CLI on principle. Newman stays only in older pipelines: it gets no updates.
Data-driven in depth: files, iterations, data isolation
In a data-driven run, iterations share environment and collection variables, so each creates its own data, cleans it up and resets temporary variables. Otherwise a test passes on leftovers from the previous row. CSV suits simple flat tables without types, while JSON keeps numbers, booleans and nested objects. Unique fields are generated in the pre-request script.
API · Runner, data-driven tests and Newman
The second CSV row fails because the first left data in variables. How do you isolate iterations?
The first row of the file created a user and wrote its id into a variable. The second row gets a 409 on a duplicate email and the third "finds" a foreign user and passes by accident. The report is green or red depending on the order. The Runner is not to blame: iterations share variables and isolation is your job. This lesson covers the file format choice, the content of the table and data cleanliness.
How it works and why it is designed so
CSV or JSON. CSV is simple and can be kept in a spreadsheet, but it has no types: do not rely on automatic conversion to a number or a boolean and convert explicitly (Number(...)). JSON preserves types (number, boolean, null) and nested objects, so it suits complex request bodies. A typical mistake: in JSON the field "ok": true is a boolean while the test compares it with the string 'true'.
What the table should contain. Input values, the expected status and, if needed, expected response fields. Rows are boundary values, equivalence classes, negative cases and a permission matrix ("role, action, expected code"). Compose the test name from the row values so the report shows what exactly failed.
Data isolation between iterations. Environment and collection variables live between iterations: a value from iteration 1 is visible in iteration 2, and a test that relies on it may pass by accident. Local variables (pm.variables) live within a run, not one request. So each iteration must be responsible for its own data: create, use, clean up.
Iterations without isolation and with it
Bad
Data from iteration 1 stayed
An environment variable lives between iterations: iteration 2 sees a foreign id and may pass by accident.
Good
Each iteration creates and cleans its own
Unique fields are generated, temporary variables are reset, what was created is deleted at the end.
Figure 1. The same rows give different results if iterations share leftovers.
Example: a JSON file and isolation scripts
In JSON numbers stay numbers, and the request body reads them as { "amount": {{amount}}, "currency": "{{currency}}" }: a number without quotes, a string with quotes.
Isolation scripts: unique fields are generated in a pre-request (otherwise the second row gets a 409 on a duplicate), the id for cleanup is stored and reset at the end of the iteration:
// Pre-request: a unique value for each iterationconst n = pm.info.iteration; // iteration number from 0
pm.variables.set('email', 'user' + n + '+' + Date.now() + '@example.test');
// Post-response: keep the id for cleanup
pm.environment.set('createdId', pm.response.json().id);
// Post-response of the last request of the iteration (after DELETE in Cleanup)
pm.environment.unset('createdId'); // do not leave it for the next iteration
Data created by a test is cleaned up at the end of the iteration: a Cleanup folder with DELETE by the stored id. A failed test does not stop the run, so cleanup will execute. An exception: in Newman with the --bail flag the run stops after the first failure and Cleanup may not run. Do not rely on data that is already in the database: a test creates its own. For cleanup and priorities see the lesson on test data.
Limits and alternatives
The iteration flow can be controlled: pm.info.iteration and pm.info.iterationCount give the number and the count, and pm.execution.setNextRequest changes the request order. Complex branching is better not to build in Postman: it reads poorly and is harder to test, and then code gives a cleaner result. The Runner's run settings have a variable-persistence option ("Keep variable values"): it decides whether the changes remain after the run. Check its state if the next run picks up leftovers of the previous one.
Common mistakes
Leftovers in variables between iterations. A test passes thanks to foreign data. Reset temporary variables with unset;
A fixed email or order number in all rows. The second row gets a 409. Generate unique values;
Comparing a boolean with a string. In JSON it is true while the test expects 'true';
Created data without cleanup. The database grows and later runs break on duplicates;
Dependence on another iteration. A test that waits for the previous row's data cannot be run alone.
Check yourself
Iteration 1 stored createdId in an environment variable, iteration 2 did not create one, yet the test on createdId passed. Why is that dangerous?
Answer
Environment variables live between iterations, so iteration 2 used a foreign value and the green test proved nothing. Creation and cleanup must be in every iteration and temporary variables are reset with unset.
When is a JSON file better and when is CSV?
Answer
CSV for simple flat tables kept in a spreadsheet. JSON when types (number, boolean, null) or nested objects in the request body are needed.
Related lessons: “Collection Runner and data-driven tests”, “Newman in CI: flags, reports, exit codes, Postman CLI”, “Equivalence classes and boundary values for fields and parameters”, “Test data, cleanup and risk-based priorities”.
In an interview.Junior: For data-driven runs I use CSV for simple tables and JSON when types or nested bodies are needed. I compose the test name from the row values and make sure iterations do not share data. Middle/Senior: Each iteration generates its own unique fields, cleans up what it created and resets temporary variables, because environment variables live between iterations. The table rows are boundaries, equivalence classes and a permission matrix, and complex branching goes into code.
Newman in CI: flags, reports, exit codes, Postman CLI
Newman exits with a non-zero code when at least one test fails, so the CI step turns red by itself. The exit code is not silenced with || true or a pipe without pipefail. The cli reporter prints to the console, while junit and htmlextra write files that are stored as an artifact with if: always(). The official Postman CLI (postman collection run) also runs collections by ID from Postman.
API · Runner, data-driven tests and Newman
Newman failed overnight and there is no report among the artifacts. What is missing in the step?
The night job failed and in the morning you open the artifacts and there is no report: the upload step did not run because the previous one was red. Another time it is the opposite: tests failed for a week while the pipeline stayed green because someone appended || true so it would "not get in the way". Both cases are about the same thing: what happens to Newman's exit code and where the report lives. The lesson covers flags, reporters, the exit code and the Postman CLI.
How it works and why it is designed so
The exit code. Everything passed: 0. If at least one test fails (or an execution error occurs), Newman exits with a non-zero code and the CI step turns red. So you do not need to check the code separately, but you must not suppress it: the pipeline would be always green. The same goes for the pipe newman run … | tee log: in bash without pipefail the pipe's code is the code of the last command, so Newman's failure disappears. In GitHub Actions a step with an explicit shell: bash runs with pipefail and without it does not, so for a log prefer a reporter.
What happens to the exit code
Wrong
The exit code is lost
newman run … || true or a pipe | tee log without pipefail: the step is green although tests failed.
Right
The exit code reaches CI
Run Newman without suppression and use a reporter for the log, not redirection.
Figure 1. A red step works only when Newman’s exit code reached CI.
A red Newman run: what to read in it
❏ Transfers
↳ Create transfer
1POST https://stage.shop.test/v1/transfers [400 Bad Request, 412B, 143ms]
1. Status is 201
# failure detail
2 1. AssertionError Status is 2013expected response to have status code 201 but got 400
at assertion:0 in test-script
4 inside "Transfers / Create transfer"
What arrived: the server answered 400, not 201. The code is already visible in the request line.
Which test: the name from pm.test, use it to find the check in the script.
Why: expected code against the received one. This is the effect; look for the cause in the response body.
Where: the request and its folder in the collection: start the investigation here.
What to do
Reproduce the request with the same environment and body and read the 400 response: raw requests and responses are in the htmlextra report. After such a failure Newman exits with a non-zero code, so the CI step is red; the report is saved only with if: always() on the upload step.
Figure 2. A typical failure in Newman output (shortened): the numbers lead to the explanations.
Main flags. The ones met most often in CI:
-e env.json, -g globals.json, -d data.csv: environment, globals, data for iterations;
--env-var "key=value": one variable from the command line, the way secrets are passed;
--folder "Name": only the given folder (the flag can be repeated); -n (--iteration-count): the number of iterations;
--bail: stop after the first failure, otherwise Newman goes through the whole collection;
--delay-request 200: a pause between requests; --timeout-request 10000: a response wait limit;
-r cli,junit,htmlextra: reporters, each with its own export file (--reporter-junit-export, --reporter-htmlextra-export).
Which reporters for what.cli: a log for humans in the CI console. junit: a machine format that Jenkins, GitLab and GitHub tooling understand to show tests in the interface. htmlextra (a separate package newman-reporter-htmlextra): HTML with raw requests and responses for analysing failures.
Example: one command with all the flags
# environment, data and iterations, one folder, secret from CI;# --bail stops the run at the first failure
newman run api.postman_collection.json \
-e stage.postman_environment.json \
-d transfers.csv -n 5 \
--folder "Transfers" \
--env-var "apiKey=$API_KEY" \
--delay-request 200 --timeout-request 10000 \
--bail \
-r cli,junit,htmlextra \
--reporter-junit-export results/newman.xml \
--reporter-htmlextra-export results/report.html
In GitHub Actions the same run looks like this. if: always() is needed so the report is saved exactly when tests fail: otherwise there is no artifact when it is needed most.
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- run: npm i -g newman@6 newman-reporter-htmlextra@1
- name: API regression
run: >
newman run api.postman_collection.json
-e stage.postman_environment.json
--env-var "apiKey=${{ secrets.API_KEY }}"
-r cli,junit,htmlextra
--reporter-junit-export results/newman.xml
--reporter-htmlextra-export results/report.html
- uses: actions/upload-artifact@v7
if: always() # the report is needed exactly when tests failwith:
name: newman-report
path: results/
The Postman CLI. This is Postman's official tool: after signing in with an API key, postman collection run runs a collection from the cloud workspace by ID, and a local collection file as well.
# Postman CLI: sign in with an API key, then run by collection ID
postman login --with-api-key "$POSTMAN_API_KEY"
postman collection run <collection-id>
# a local collection file can be run without signing in too
postman collection run ./api.postman_collection.json
Newman or the Postman CLI
Newman
A collection file in the repository
A run from v2.1 JSON in the repository with no login, many reporters, the version is pinned by the repository.
Postman CLI
A collection in the cloud workspace
A run by ID with the current version and no export; results are visible in Postman; an API key is required.
Figure 3. The choice depends on where the collection lives: in the repository or in the cloud workspace.
Limits and alternatives
Run hygiene: pin the versions of Newman and reporters, do not run a collection with unsafe writes against production, keep the CI environment separate and with test data. Newman does not support the Vault, and newer script features can appear in the app before they reach Newman: one more argument to verify the collection on the pipeline's version. The choice between Newman and the Postman CLI depends on where the collection lives: a file in the repository gives a reproducible run together with the code, while the cloud workspace gives an always current version without an export. Newman reads only v2.1 JSON; a collection in the new YAML format (a file per request, Native Git) runs only in the Postman CLI.
Common mistakes
|| true or | tee without pipefail. The pipeline is green while tests are red;
A report without if: always(). There is no artifact exactly when it is needed;
One export file for two reporters. Each reporter needs its own path;
The --bail flag where cleanup is needed. The run stops and Cleanup does not execute;
Unpinned versions. A new release breaks the pipeline with no change in the collection.
Check yourself
The pipeline has newman run … || true. What follows from that?
Answer
Newman's exit code is ignored, so the step is always green even when tests fail. Remove || true and keep the report with a separate step using if: always().
Why three reporters cli,junit,htmlextra and why different files?
Answer
cli for a human in the log, junit for a machine display of tests in CI, htmlextra for failure analysis with raw requests. The files differ because each reporter writes to its own export.
Related lessons: “Newman and CI”, “Data-driven in depth: files, iterations, data isolation”, “Secrets, mock servers and monitors in Postman”.
In an interview.Junior: I run newman run with an environment, JUnit and HTML reporters and pass secrets through --env-var. I keep the report as an artifact with if: always() and I do not suppress the exit code. Middle/Senior: I pin Newman and reporter versions, keep a separate CI environment with test data and make sure pipes do not lose the exit code (pipefail). I choose Newman or the Postman CLI by where the collection lives: a file in the repository or the cloud workspace.
Newman or Postman CLI: what to choose for CI
Newman runs only an exported v2.1 JSON and is no longer updated, while the Postman CLI is the recommended tool for running collections in CI. The CLI opens collections from the cloud and the v3 format, runs packages and has a built-in HTML report. An existing Newman step is migrated by checking flags and reporters (--folder becomes -i) and by not enabling -x, which hides failures.
A nightly collection run in CI has worked on Newman for years. Then the team moves to the Git-based collection format and adds shared packages to scripts, and the step fails: Newman understands neither the new format nor packages. This is not a breakage but the limit of a tool, so the choice between Newman and the Postman CLI is worth making deliberately.
What the Postman docs say. Newman is described as an open-source tool that no longer receives updates and fixes: the docs advise replacing it in scripts and CI with the Postman CLI, and that CLI is called the recommended tool for running collections locally and in CI/CD. So for a new pipeline the choice is usually clear, and the question arises with existing steps.
Comparison by substance.
Where the collection comes from. Newman runs an exported JSON in the v2.1 format (a file or a link with an API key). The Postman CLI runs a collection by ID from the cloud after sign-in or by a path to a local file; the v3 format from Local View, which the Git mode needs, cannot be run by Newman but can by the Postman CLI. The CLI shows the results of a local run in the terminal and sends them to Postman only when you are signed in and the collection is run by ID or linked to a cloud collection (Native Git);
Sign-in and key. Newman needs no account. For the CLI, sign-in is needed to run cloud collections and send results: postman login, the --postman-api-key option or the POSTMAN_API_KEY variable. In CI the key comes from secrets;
Packages. The contents of Package Library packages imported with pm.require do not run in Newman; the Postman CLI runs them in collection runs and monitors, but running a collection with packages requires a Solo, Team or Enterprise plan;
Reports. An HTML report in Newman needs a separate reporter package, in the CLI it is built in: -r html. The CLI has the cli, json, junit and html reporters, but for collections in the v3 format (YAML: HTTP, gRPC or GraphQL) and for collections with Kafka requests only cli is available, so a pipeline that needs JUnit still runs a v2.1 collection for now;
Capabilities. Newman only runs collections. The Postman CLI also supports monitors, mock servers and other Postman features, and publishes local changes to the cloud.
Migration: where it breaks. Most flags match: -e, -g, -d, --bail, -r. The differences people run into: --folder becomes -i, the CLI has no --export-environment, --export-globals and --export-collection options, and the HTML reporter no longer needs a separate package.
# before
- run: npm i -g newman newman-reporter-htmlextra
- run: newman run api.postman_collection.json -e stage.postman_environment.json --folder Smoke -r cli,htmlextra
# after
- run: npm install -g postman-cli
- run: postman login --with-api-key "${{ secrets.POSTMAN_API_KEY }}"
- run: postman collection run api.postman_collection.json -e stage.postman_environment.json -i Smoke -r cli,html
Exit code. Like Newman, the CLI exits with a non-zero code when a check fails, and the CI step turns red. The -x flag (suppress exit code) makes it exit with 0 even when tests fail: do not enable it in CI because it masks a failure. Both tools have -x, so it is easy to carry over with the rest during a migration.
How to choose.
A new pipeline, or a collection in the Git v3 format, packages, monitors: the Postman CLI;
An existing Newman pipeline with a v2.1 collection and no packages: it works, but the tool has no updates: plan the migration without waiting until it becomes urgent;
The collection lives in a cloud workspace and the current version is always needed: the CLI by ID without an export;
A run without an account, for example in a fork or an environment without secrets: a local file and Newman, or the CLI without signing in.
Common mistakes.
Carry the command over and not check the reporters: the JUnit or HTML report the pipeline waits for is missing;
Leave -x after debugging: the step is green while tests fail;
Run a collection with pm.require in Newman: imports do not work, and the failure looks like a script error;
Put the API key into the repository instead of CI secrets.
Check yourself
A collection with pm.require passes in the Postman app, but the nightly step with newman run fails. What to do?
Answer
The contents of packages do not run in Newman. Run the collection through the Postman CLI (mind the plan that allows packages); rewrite the scripts without packages only if the step has to stay on Newman.
After the migration to the Postman CLI CI turned green although some collection tests fail. Where to look for the cause?
Answer
Most likely -x (suppress exit code) got into the command, or a wrapper such as || true swallows the exit of the command. Without them a non-zero exit code fails the step.
Related lessons: "Newman in CI: flags, reports, exit codes, Postman CLI", "Collection Runner and data-driven tests".
In an interview.Junior: Newman and the Postman CLI run a collection from the command line and return a non-zero code when a test fails; the CLI is Newman's successor. Senior: for a new pipeline I take the Postman CLI because Newman gets no updates and does not handle the v3 format and packages; an existing Newman step I migrate by checking flags and reporters and not enabling -x.