Generate collection run reports with Newman built-in reporters
Newman has built-in reporters you can use to generate reports for your collection runs. The following reporters are available: CLI, JSON, JUnit, Progress, and Emoji train. You can use more than one reporter for a run, and you can customize the report output to meet your needs.
Use built-in reporters
To generate reports of the current collection run, you can configure reporters using the -r or --reporters options. Then specify the reporters you’d like to generate reports for: cli, json, junit, progress, or emojitrain.
You can specify one or more reporters. If you specify more than one reporter, separate reporter names as a comma-separated list, for example, -r cli,json. To learn more about each reporter, see About built-in reporters.
The CLI reporter (cli) is turned on by default when using Newman in the terminal. If you turn on one or more reporters, for example -r json, the CLI reporter will be turned off. To turn on the CLI reporter, you must specify the CLI reporter, for example, -r cli,json.
The following example runs the cli and json reporters:
If the built-in reporters aren’t right for your use case, you can use an external reporter or build a custom reporter.
About built-in reporters
Each reporter generates a report about your collection run in a different format.
- CLI — Displays the report in the terminal.
- JSON — Creates a JSON file containing the report.
- JUnit — Creates an XML file containing the report.
- Progress — Displays a progress bar in the terminal showing the progress of the collection run.
- Emoji train — Displays emojis in the terminal that represent the report’s details.
Configure built-in reporters
If you specify more than one reporter, you can specify an option for one reporter using the --reporter-[reporter-name]-[reporter-option] option. The following example silences the CLI reporter only:
If you specify more than one reporter, and you want all reporters to accept the same option, you can specify an option for all reporters using the --reporter-[reporter-option] option. The following example passes silent: true to both the CLI and JSON reporters:
CLI reporter
The CLI reporter is turned on by default when using Newman as a CLI, and prints the report to the terminal. You can use the following options to configure the CLI reporter:
The CLI reporter is turned off, and you don’t see an output in the terminal.
Prints the local time that each request was made.
Doesn’t print the statistical summary table.
Doesn’t print the details for run failures.
Turns off the output for assertions as they happen.
Turns off the output for successful assertions as they happen.
Turns off the output of console.log() (and other console methods) from pre-request and post-response scripts.
Turns off the Newman banner shown at the beginning of each collection run.
The following example prints the time that each request was made:
JSON reporter
The JSON reporter creates a JSON file in your working directory that contains the report. You can use the following option to configure the JSON reporter:
Specify a path where the output JSON file will be created in your file system. By default, the JSON file is created in /newman in your working directory. If the /newman directory doesn’t exist, it will be created. If the specified path is an existing directory, the file will be created in that directory.
Optionally, you can specify a name for the file, for example, ... --reporter-json-export collection-run-1.json.
The following example generates the output JSON file for the JSON reporter in the /json-file-reports directory:
JUnit reporter
The JUnit reporter creates an XML file in your working directory that contains the report. You can use the following option to configure the JUnit reporter:
Specify a path where the output XML file will be created in your file system. By default, the XML file is created in /newman in your working directory. If the /newman directory doesn’t exist, it will be created. If the specified path is an existing directory, the file will be created in that directory.
Optionally, you can specify a name for the file, for example, ... --reporter-junit-export collection-run-1.xml.
The following example generates the output XML file for the JUnit reporter in the /xml-file-reports directory: