Generate collection run reports using the Postman CLI

View as Markdown

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. All built-in reporters are available for HTTP collections in v2 format (JSON). Only the CLI reporter is available for HTTP, gRPC, and GraphQL collections in v3 format (YAML).

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. JSON and HTML reports also include details about failed requests ran from scripts at the collection and folder levels. 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. Note that gRPC and GraphQL collection runs only support the CLI report.
  • 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. You can filter your collection run iterations by test failures or errors, or by test failures only. Then select the iteration you’d like to view from the filtered results. You can also filter the requests within each iteration to show requests that encountered test failures or errors, or errors only.

Usage

You can generate a report for one or multiple reporters when you run a collection with the postman collection run command.

Use one 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> -r <reporter> [options]

You can find the collection ID in Postman. Click the Items icon Items tab in the sidebar, click Collections, then select a collection. Then click the Info icon Info tab in the right sidebar to view or copy the collection ID.

JSON, JUnit, and HTML reports are created inside the directory /postman-cli-reports in the current working directory by default. 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 multiple built-in reporters

You can specify multiple 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> -r cli,json [options]

Options

You can configure options for the CLI reporter, and for the JSON, JUnit, and HTML reporters. You can also specify options that apply to all reporters you’re using in a collection run.

Configure options for 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.

--reporter-cli-silent

Turns off the CLI reporter, and no output is displayed in the terminal.

--reporter-cli-show-timestamps

Prints the local time that each request was made.

--reporter-cli-no-summary

Doesn’t print the statistical summary table.

--reporter-cli-no-failures

Doesn’t print details for run failures.

--reporter-cli-no-assertions

Turns off output for assertions as they happen.

--reporter-cli-no-success-assertions

Turns off output for successful assertions as they happen.

--reporter-cli-no-console

Turns off console.log() output (and other console methods) from pre-request and post-response scripts.

--reporter-cli-no-banner

Turns off the banner shown at the beginning of each collection run.

Configure options for 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 reporters. Replace <reporter> with the reporter you’re using: json, junit, or html.

--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’s automatically created. If the specified path is an existing directory, the report file is 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> -r json,html --reporter-json-omitHeaders

If you want JSON, JUnit, and HTML reporters to accept the same option, specify a reporter option for all reporters using the syntax --reporter-<option>.

$postman collection run <collection> -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.

Examples

$postman collection run 12345678-12345ab-1234-1ab2-1ab2-ab1234112a12 -r json\
>--reporter-json-omitHeaders
$
$postman collection run 12345678-12345ab-1234-1ab2-1ab2-ab1234112a12 -r cli,junit,html\
>--reporter-cli-show-timestamps\
>--reporter-junit-export path/to/junit-report-file\
>--reporter-html-export path/to/html-report-file