If you are using Postman for API testing and have developed your test cases in Collections, then you can execute these with newman.
Assuming that you already have VSTS account created, you can follow the below steps to run the collections as CI build generation step.
Export Postman Collection and Environment variables
- Select your Postman Collection and export it and save it-
2. Export the environment variables by clicking on gear icon and as well-
3. Save these files in your local Git report as shown-
4. Push these files to VSTS Project.
>> git add .
>> git commit -m “Postman Collection and environment files”
> git push
5. Verify that the files are showing up in repo in VSTS-
6. Create new Build pipeline in VSTS, select your team project and repository and click Continue –
7. Select “Empty Job” template-
8. Click on ‘+’ sign on Agent job 1, Search npm and add the task-
9. Configure npm task with shown values-
Display name: Whatever you like
Command: Select “custom” from drop down
Command and Arguments: install -g newman
10. Add another task “Command Line” –
11. Configure Command Line task-
Arguments: run $(Build.SourcesDirectory)\CoreAPITest\CoreAPI.json -e $(Build.SourcesDirectory)\CoreAPITest\CoreEnv.json –reporters junit –reporter-junit-export report.xml
12. Search and add another task “Publish Test Results”-
13. Configure Test result task-
Test results files: **/report*.xml
14. Save and queue the build for generation using “Hosted 2017” Agent pool:
15. The build logs will show the task execution something like below-
16. The test results will be available in Tests tab as shown below-