We use different test cases to test numerous requests and get results in the Postman application. We should consider some report handler if we want to present those results. Newman is one of the reporting tools we need to explore in that situation. It is a command-line collection executer for Postman. It permits you to efficiently run and test a Postman collection directly from the command-line.
Installation: The simplest and more popular method to install Newman is by using the NPM. First, we just need to install node.js in our system. After that, Newman’s installation is a piece of cake. We need to follow these steps to install Newman:
- Open Command Prompt as administrator.
- To verify the Node.js installation type the “node” command and press enter, the system will then display node.js version. Press control plus C to take control of it. Your node.js is not installed if you do not get node.js version
- Run “npm install -g newman” and press enter. The system will take some time to install Newman packages.
Simple reports by Newman:
To generate reports for Newman, we need to switch to the Postman application and navigate to the “Collections”. Then, we will use the collection’s public URL link to generate its report. This process consists of the following steps:
- Expand the collection through the left arrow and click on the share button, as seen in the screenshot below:
- The system will display a popup window, click on the “Get public link tab” on the window.
- The system will now display a URL link; copy that URL.
Now we need to set the directory on CMD from where we will generate the collection report and type Newman run ‘copied collection link’ and press enter. The report will be generated and, thus, ready for review.
Advanced HTMLExtra Reports
A downside of the Newman reports is that they are structurally simple and do not have captivating UI. For reporting needs, it is required that the information is available immediately, and at the same time, be pleasing to the eyes of the viewers l. The Newman HTMLExtra package provides custom reports with enhanced visuals, including distinguished success and failure scenarios. You can install the Newman HTMLExtra package using the following command on CMD:
“npm install -g newman-reporter-htmlextra”
You can also use the same URL used in Newman’s simple report for the Htmlextra report. To do so, you need to enter the following command to generate a report which can be presentable everywhere.
“newman run https://www.getpostman.com/collections/e62d46e17ee86d46ebe3 --reporters=cli,htmlextra”
Features in the HTMLExtra Report:
- Separate views for summary and requests. There is also a separate tab to view the failed requests.
- Many customizations are accessible with the reporter, like displaying console logs, hiding skipped tests, displaying only failures in the reports, etc.
- Color-coding to differentiate failures and success visually.
- Interactive tabbed views as well as expand/collapse options for request details.
- All the request responses are captured fully, including the header information.
As you can see, Newman is a powerful tool for API test reporting. However, to accomplish the dream results and save time and effort, it must be used smartly using the HTML extra plugin.
In this blog, we learned about . We also reviewed another HTML reporter named Newman-reporter-htmlextra that generates better-styled reports with different views for Summary requests and failed requests.
Please do not hesitate to reach out to me if you have any questions or queries!