Created
September 11, 2020 14:12
-
-
Save aimtiaz11/51f7e84d25d35252e8eb35d847a20587 to your computer and use it in GitHub Desktop.
Azure DevOps - Execute automated API tests using newman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Node.js | |
| # Build a general Node.js project with npm. | |
| # Add steps that analyze code, save build artifacts, deploy, and more: | |
| # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript | |
| trigger: | |
| - master | |
| parameters: | |
| - name: project | |
| displayName: Select your project | |
| type: string | |
| default: project-a | |
| values: | |
| - project-a | |
| - project-b | |
| - project-c | |
| - project-d | |
| - name: environment | |
| displayName: Select your Environment | |
| type: string | |
| default: dev | |
| values: | |
| - DEV | |
| - TEST | |
| - UAT | |
| pool: | |
| vmImage: 'ubuntu-latest' | |
| steps: | |
| - task: DownloadSecureFile@1 | |
| name: TEST_envFile | |
| displayName: Download TEST.json environment file | |
| condition: eq('${{parameters.environment}}', 'TEST') | |
| inputs: | |
| secureFile: 'TEST.json' | |
| - task: DownloadSecureFile@1 | |
| name: UAT_envFile | |
| displayName: Download UAT.json environment file | |
| condition: eq('${{parameters.environment}}', 'UAT') | |
| inputs: | |
| secureFile: 'UAT.json' | |
| - script: | | |
| echo Downloaded $(${{parameters.environment}}_envFile.secureFilePath) to here... | |
| displayName: Echo path to secure file | |
| - task: NodeTool@0 | |
| inputs: | |
| versionSpec: '10.x' | |
| displayName: 'Install Node.js' | |
| - script: | | |
| ls -ltr | |
| npm install | |
| newman run ${{ parameters.project }}/postman_collection.json -e $(${{parameters.environment}}_envFile.secureFilePath) --reporters cli,junit --reporter-junit-export result/test-result.xml | |
| displayName: 'Run Newman Test' | |
| continueOnError: true | |
| - task: PublishTestResults@2 | |
| inputs: | |
| testResultsFormat: 'JUnit' | |
| testResultsFiles: '**/test-*.xml' | |
| searchFolder: '$(System.DefaultWorkingDirectory)/result/' | |
| testRunTitle: 'Publish Newman Test Results' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment