Generate Standard HTML and Advanced HTML reports.
In Postman, we use several test cases to test a variety of requests and obtain results. If we wish to capture these results, we should think about using a report handler. This can be achieved using Newman which is a powerful command-line collection runner for Postman.
In my previous article Run Collections using Newman, I have covered how to install Newman and different ways to run a collection using Newman.
In this post, we will learn “How To Generate Standard HTML and Advanced HTML Reports Using Newman”.
Why do we need HTML Reports?
HTML reports are quite helpful. If any of our tests fail, we get a summary of what happened. We can keep a check on the tests that run every night or multiple times a day and also helps in debugging.
How to Generate Standard HTML Reports
- Install Newman Reporter using the below command in CMD.
2. Copy the Collection URL and download the environment variables using Postman as shown below.
· Hover your mouse over the three dots next to the collection name and click on share collection.
· Click on Get Public link
· Copy the link below
· Download the environment json file by navigating to environments, click on the 3 dots and click export
· Save the Json file to your computer
· Open your shell (command prompt for windows and terminal for mac) where the environment variable file is stored on your system and run the following
newman run <above link> - environment “name of the environment file” -r html
3. The report will be saved inside the folder where Newman was executed, inside a folder called Newman.
Standard HTML Report:
As we can see from the above report that the Standard HTML Report format generated by the Newman Html reporter is good but not exceptionally great. It doesn’t have a really appealing user interface, and the content isn’t particularly brief or well-organized.
For reporting purposes, it is necessary that the information be accessible at first sight while also attractive to the viewers’ eyes. As a result, the standard HTML Reporter design can be customized or updated to make the reports look nicer and more user-friendly.
So Now let us learn how to generate customized HTML reports.
How to Generate Advanced HTML Reports(Customized Reports).
- Install the Newman HTMLExtra package using the below command on CMD.
2. Open your shell (command prompt for windows and terminal for mac) where the environment variable file is stored on your system and run the following.
newman run <abovelink> — environment “name of the environment file” -r cli,htmlextra
3. The report will be saved inside the folder where Newman was executed, inside a folder called Newman.
Features in the HTMLExtra Report:
- Separate views for summary and requests. There is also a separate tab to view the failed requests.
2. The reporter allows for a variety of customizations, such as displaying console logs, hiding skipped tests, and simply displaying failures in reports, among others.
3. Color-coding helps visually distinguish failures and success.
4. Interactive tabbed views as well as expand/collapse options for request details.
5. All the request and responses including header information are captured.
Advanced HTML Report
It also displays headers and payloads for the requests and the responses.
Conclusion
As you can see, Newman is an extremely useful tool not only for running the collections but also for reporting API tests. While numerous HTML reports can be created, the Newman-reporter-htmlextra creates better-looking and detailed report with separate tabs for Summary, Total Requests, Failed and Skipped Tests.