Generate collection run reports using the Postman CLI

The Postman CLI has built-in reporters you can use to generate reports for your collection runs. The following reporters are available: CLI, JSON, JUnit, and HTML. You can use more than one reporter for a run, and you can customize the report output to meet your needs.

About built-in reporters

Each Postman CLI reporter generates a local report with details about a collection run, including the requests sent, response codes and times, and the number of passed and failed tests. The following reporters are available:

  • CLI - Displays a report in the terminal. The CLI report is displayed by default if no reporter options are specified.
  • JSON - Creates a JSON file containing the report. By default, the report structure follows the Postman CLI JSON reporter schema. You can optionally generate a report using the Newman JSON reporter schema (example).
  • JUnit - Creates an XML file containing the report. To learn more about JUnit reporting, see the JUnit documentation.
  • HTML - Creates an HTML file containing the report.

Use a built-in reporter

To generate a report for a collection run, use the -r or --reporters option. Then specify the reporter you want to use to generate the report: cli, json, junit, or html. Use the following syntax:

postman collection run <collection-id> -r <reporter>

You can find the collection ID in Postman. Select Collections in the sidebar and select a collection. Then select Info Info icon in the right sidebar to view or copy the collection ID.

By default, reports are created inside the directory postman-cli-reports in the current working directory. If the postman-cli-reports directory doesn't exist, it's automatically created. You can also specify an output directory. The filename includes the collection name and a system timestamp in 24-hour format: collection-name-yyyy-mm-dd-hh-mm-ss.

Use more than one reporter

You can specify one or more reporters for a collection run. If you specify more than one reporter, separate the reporter names in a comma-separated list, for example, -r json,junit.

By default, CLI reporter output is shown in the terminal when you run a collection. If you specify one or more reporters, for example -r json, then CLI reporter output isn't shown. In this case, to show the CLI reporter, you must explicitly specify it along with the other reporters, for example: -r cli,json.

The following example runs the cli and json reporters:

postman collection run <collection-id> -r cli,json

Configure built-in reporters

You can customize the output of each reporter by including one or more options when running the command. Use the following syntax:

postman collection run <collection-id> -r json <--reporter-json-option1> <--reporter-json-option2>

The following example runs the json reporter with the omit headers and omit response bodies options:

postman collection run <collection-id> -r json --reporter-json-omitHeaders --reporter-json-omitResponseBodies

Configure the CLI reporter

The CLI reporter is turned on by default when running a collection with the Postman CLI and prints the report to the terminal. Use the following options to configure the CLI reporter.

OptionDetails
--reporter-cli-silentTurns off the CLI reporter, and no output is displayed in the terminal.
--reporter-cli-show-timestampsPrints the local time that each request was made.
--reporter-cli-no-summaryDoesn't print the statistical summary table.
--reporter-cli-no-failuresDoesn't print details for run failures.
--reporter-cli-no-assertionsTurns off output for assertions as they happen.
--reporter-cli-no-success-assertionsTurns off output for successful assertions as they happen.
--reporter-cli-no-consoleTurns off console.log() output (and other console methods) from pre-request and post-response scripts.
--reporter-cli-no-bannerTurns off the banner shown at the beginning of each collection run.

Configure the JSON, JUnit, and HTML reporters

The JSON, JUnit, and HTML reporters create a report file in the specified format in your working directory. Use the following options to configure the reporter. Replace <reporter> with the reporter you are using: json, junit, or html.

OptionDetails
--reporter-<reporter>-export <path>Specify a path to save the report. By default, reports are saved to the /postman-cli-reports directory in your current working directory. If the directory doesn't exist, it will be created automatically. If the specified path is an existing directory, the report file will be saved within it.
--reporter-<reporter>-omitRequestBodies(JSON and HTML reporters only) Remove all request bodies from the report.
--reporter-<reporter>-omitResponseBodies(JSON and HTML reporters only) Remove all response bodies from the report.
--reporter-<reporter>-omitHeaders(JSON and HTML reporters only) Remove all request and response headers from the report.
--reporter-<reporter>-omitAllHeadersAndBody(JSON and HTML reporters only) Remove all request and response headers, and all request and response bodies, from the report.
--reporter-json-structure newman(JSON reporter only) Generate a JSON report using the Newman schema. By default, JSON reports use the native structure of the Postman CLI.

Configure options for more than one reporter

If you're using more than one reporter, you can specify an option for a single reporter using the syntax --reporter-<reporter>-<option>. Replace <reporter> with the reporter you are using: cli, json, junit, or html. Replace <option> with the reporter option you want to apply to the reporter.

postman collection run <collection-id> -r json,html --reporter-json-omitHeaders

If you want all reporters to accept the same option, you can specify a reporter option for all reporters using the syntax --reporter-[option].

postman collection run <collection-id> -r json,html --reporter-omitHeaders

When using more than one reporter, options specified for a single reporter take precedence over options specified for all reporters.

Last modified: 2024/12/16