Generating HTML report for API testing using Newman.
Introduction
In this article, I will explain how to generate HTML reports for API testing using Newman.
Pre Requisites
- Postman Tool.
- A collection containing APIs.
Postman
Postman is a widely used API(application programming interface) development tool which helps to build, test and modify APIs. All the functionality needed by any developer is available in this tool. It can make various types of HTTP requests ( GET, POST, PUT, PATCH).
About Newman-html extra
Newman is a command line collection runner. Using Newman we can run and test Postman collection directly from the command line. Using Newman the collection can also be integrated with CI/CD tools like Jenkins, Azure DevOps. HTML Extra is a Postman/Newman reporting Dashboard which provides Postman test result into interactive UI.
To Generate the HTML extra dashboard report first we need to export Postman Collection:
Steps to Generate report using the Postman Collection:
- First we need to install the latest version of Node.js.
- Install Newman using the below command
npm install -g Newman
3. Install HTML Extra Reporter( Install it globally so that it can be used from any path)
npm install -g newman-reporter-htmlextra
Now we are all set to generate the HTML report for our Postman Collection.
Steps for running the collection and generating the report:
- Navigate to the path where collection has been exported.
- Open command prompt.
- run the below command:
newman run <path of your collection> --reporters cli,junit,htmlextra --reporter-junit-export <path where Junit report need to be generated> --reporter-htmlextra-export <path where html report need to be generated> --delay-request 5000
After running the above command navigate to the path provided in the command, you will get report as below:
About the Author:
Shubham Pandey is a Test Engineer at Version 1.