Skip to content

Instantly share code, notes, and snippets.

@aimtiaz11
Created September 11, 2020 14:12
Show Gist options
  • Select an option

  • Save aimtiaz11/51f7e84d25d35252e8eb35d847a20587 to your computer and use it in GitHub Desktop.

Select an option

Save aimtiaz11/51f7e84d25d35252e8eb35d847a20587 to your computer and use it in GitHub Desktop.
Azure DevOps - Execute automated API tests using newman
# 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