Postman is the collaboration platform for API development. You can use postman to automate your API test.
Postman contains a collection runner. In a collection there is a group of requests.
After you run a collection, you need generate test report. You can generate it using simple CLI command below:
- XML Report using — reporter-junit
- HTML Report using — reporter-html
- HTML Report using — reporter-html-extra
Before generate report, you have to prepare collection JSON file and environment JSON file if there is dependency between them. (I will explain how to export collection to JSON file in a separate post)
- XML Report using — reporter-junit
Open command prompt and type command below:
newman run C:\Users\<myself>\Desktop\Tests.postman_collection.json -e C:\Users\<myself>\Desktop\Tests.postman_environment.json - reporters cli,json,junit - reporter-junit-export C:\Users\<myself>\Desktop\my_report_name.xml
If you store variable in collection or request directly (no variable in environment), you don’t need ‘-e’. The CLI command will be:
newman run C:\Users\<myself>\Desktop\Tests.postman_collection.json - reporters cli,json,junit - reporter-junit-export C:\Users\<myself>\Desktop\my_report_name.xml
2. HTML Report using — reporter-html
Open command prompt and type command below:
newman run C:\Users\<myself>\Desktop\Tests.postman_collection.json -e C:\Users\<myself>\Desktop\Tests.postman_environment.json - reporters cli,html,json,junit - reporter-html-export C:\Users\<myself>\Desktop\my_report_name.html
You can generate xml and html report in once with this CLI command:
newman run C:\Users\<myself>\Desktop\Tests.postman_collection.json -e C:\Users\<myself>\Desktop\Tests.postman_environment.json - reporters cli,html,json,junit - reporter-junit-export C:\Users\<myself>\Desktop\my_report_name.xml - reporter-html-export C:\Users\<myself>\Desktop\my_report_name.html - disable-unicode
I use ‘— disable-unicode’ to force the unicode disable option and all symbols in the output will be replaced by their plain text equivalents.
. HTML Report using — reporter-html-extra
Open command prompt and type command below:
newman run C:\Users\<myself>\Desktop\Tests.postman_collection.json -e C:\Users\<myself>\Desktop\Tests.postman_environment.json -r htmlextra - reporter-htmlextra-export C:\Users\<myself>\Desktop\my_report_name.html
Thanks for reading.