Integrate Postman with Azure DevOps
cicd | 2022-07-20
Step 1: Create a Collection in Postman
1.1 Create a new collection
1.2 Add a few new requests
1.3 Write test cases for the requests
1.4 Export the collection
Step 2: Set Up Your Repository
2.1 Create a new folder
2.2 Run npm init -y
2.3 Run npm install --save newman
2.4 Create a new .gitignore
file
2.5 Add these folders to .gitignore
: Results node_modules
2.6 Copy the exported collection from Step 1.4 to the root
2.7 Commit and push the repository
Step 3: Configure Azure DevOps
3.1 Create a new pipeline and reference the repository and branch from Step 2
3.2 Source settings:
Clean: True
Clean options: Source
3.3 Create an Agent Job and select an Agent Pool
3.4 Add a NPM task with the following settings:
Command: install
Working directory: $(System.DefaultWorkingDirectory)
3.5 Add a Command Line task with the following script:
"./node_modules/.bin/newman" run DevOps.postman_collection.json --reporters cli,junit --reporter-junit-export Results\junitReport.xml
(environment) Script: "./node_modules/.bin/newman" run DevOps.postman_collection.json -e myenv.postman_environment.json --reporters cli,junit --reporter-junit-export Results\junitReport.xml
Working directory: $(System.DefaultWorkingDirectory)
Continue on error: Yes
3.6 Add a Publish Result Task:
Test result format: JUnit
Test results files: $(System.DefaultWorkingDirectory)\Results\*.xml
Search folder: $(System.DefaultWorkingDirectory)
Upload test results files: Yes
Step 4: Run the Pipeline
Step 5: Verify Results
5.1 Navigate to the Tests tab next to the Summary tab