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. 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.
- 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.
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:
You can find the collection ID in Postman. Click Collections in the sidebar and select a collection. Then click Info 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:
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:
The following example runs the json reporter with the omit headers and omit response bodies options:
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.
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.
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.
If you want all reporters to accept the same option, you can specify a reporter option for all reporters using the syntax --reporter-[option].
When using more than one reporter, options specified for a single reporter take precedence over options specified for all reporters.