Backend test automation project with Postman and Newman for QA Automation Certification - Session 2
Since storing API Keys in a repository is a bad practice, the below steps can be followed to execute the postman requests in a CI/CD pipeline:
- First we need to get an Postman API Key to get the collection and env var URLs via Postman API, inside Postman there is an option to get them.
- Then we will need to fetch & Get a
uid
of the collection and environment to construct the entire URLs. - Last to run Postman test in a CI/CD we can add a job which call Newman run commands, this job can be described in a .yml file with the URLS, newman commands, docker instructions, etc.
- Clone this repo
- Get Newman to run the Postman collections:
$ npm install -g newman
- Install html reporter extra for Newman:
npm i newman-reporter-htmlextra
-
From project's root folder run the command:
newman run <colelction_file>.postman_collection.json -e <env_file>.postman_environment.json -r htmlextra --reporter-htmlextra-title "<report_title>"
Example:
newman run temporary_block_list/temp_block_to_bl/Temporary_block_to_blacklist.postman_collection.json -e API_fraud_service.postman_environment.json -r htmlextra --reporter-htmlextra-title "Temporary Block List Regression Tests"
-
Output is an HTML report created inside the folder: reports