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.
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:
newman run my-collection.json -r cli,json
If the built-in reporters aren't right for your use case, you can use an external reporter or build a custom reporter.
Each reporter generates a report about your collection run in a different format.
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:
newman run my-collection.json -r cli,json --reporter-cli-silent
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:
newman run my-collection.json -r cli,json --reporter-silent
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:
Option | Details |
---|---|
--reporter-cli-silent | The CLI reporter is turned off, and you don't see an output 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 the details for run failures. |
--reporter-cli-no-assertions | Turns off the output for assertions as they happen. |
--reporter-cli-no-success-assertions | Turns off the output for successful assertions as they happen. |
--reporter-cli-no-console | Turns off the output of console.log() (and other console methods) from pre-request and post-response scripts. |
--reporter-cli-no-banner | Turns off the Newman banner shown at the beginning of each collection run. |
The following example prints the time that each request was made:
newman run my-collection.json -r cli,json --reporter-cli-show-timestamps
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:
Option | Details |
---|---|
--reporter-json-export [path] | Specify a path where the output JSON file will be created in your file system. By default, the JSON file is created in Optionally, you can specify a name for the file, for example, |
The following example generates the output JSON file for the JSON reporter in the /json-file-reports
directory:
newman run my-collection.json -r cli,json --reporter-json-export json-file-reports
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:
Option | Details |
---|---|
--reporter-junit-export [path] | Specify a path where the output XML file will be created in your file system. By default, the XML file is created in Optionally, you can specify a name for the file, for example, |
The following example generates the output XML file for the JUnit reporter in the /xml-file-reports
directory:
newman run my-collection.json -r cli,junit --reporter-junit-export xml-file-reports
Last modified: 2024/09/16