Sunday, 23 July 2023

Run newman/postman collection from batch file with html extra report

Hi, using "call" command, one can run newman collection from a batch file. This doesn't require to open Node.js command explicitly. 

More about call : 

https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/call

Newman installation: 
https://learning.postman.com/docs/collections/using-newman-cli/installing-running-newman/

Html Extra Report: 
https://github.com/DannyDainton/newman-reporter-htmlextra

Html Extra Report Extended: 
https://www.npmjs.com/package/newman-reporter-htmlextra-extended

newman-smoke.bat

@echo on
cd C:\PostmanCollections
timeout /t 5 /nobreak

call newman run "SmokeTests.postman_collection.json" -e "QALabEnv.postman_environment.json" -r htmlextra,cli --reporter-htmlextra-export "C:\Reports\SmokeTestReport.html" --reporter-htmlextra-title "Smoke Test Dashboard - QA Lab" --reporter-htmlextra-titleSize 6 

echo 'Execution of SmokeTestscollection successful!' 


-r htmlextra, cli 
This part in the command generates html extra report as well as report output on the console. 

--reporter-htmlextra-title "Smoke Test Dashboard - QA Lab"
This part in the command gives the custom name to the report. 

 --reporter-htmlextra-titleSize 6 
This part in the command used to specify the size of the report title (1 through 6, 1 is min 6 is max) 

To redirect the batch logs from console to file add below piece of batch script at the beginning of the file. 
@echo off
set LOGFILE=smoke-log.log
call :LOG > %LOGFILE%
exit /B
:LOG

I hope you find this useful! If you like it, pls do subscribe my YouTube channel for automation or tech updates.

No comments:

Post a Comment