2022年3月28日 星期一

[Newman] HTML reporter

 Testing   Newman   Postman  


 



Introduction


This article shows how to use Newman and HTML reporter(DannyDainton/newman-reporter-htmlextra) to generate the API test report by command.

 

Environment


Postman v9.15.6

Newman 5.3.2

 

 

 

Implement


 

Install Packages

 

$ npm install -g newman
$ npm install -g newman-reporter-htmlextra



Export collection and environment variables from POSTMAN as json files

 

(Optional) remember to export variables of target environment from Postman if you use variables on the Postman’s requests.

 

 

├─ Demo.postman_collection.json
└─ Localhost.postman_environment.json

 

You can have the test scripts in Postman’s Tests, that will be also tested and show in the later HTML report.

 

e.q.

 

 

Run tests and export report

 

The following command will generate the HTML report "newman/Demo-2022-03-27-16-23-46-288-0.html".

 

$ newman run "Demo.postman_collection.json" --insecure -e "Localhost.postman_environment.json" -r htmlextra

 

 

The HTML report includes request, response and the result of test scripts.

 

 

 

 

 

Reference


postmanlabs/newman

DannyDainton/newman-reporter-htmlextra

Newman Action