Improve this page

Introduction

Two files are in this folder:

- task: AzurePowerShell@3
  displayName: 'Run Tests'
  inputs:
    azureSubscription: 'sogeti-core-cloudboostsite-p'
    ScriptPath: '_pipelines/VSTS/PowerShellScripts/PesterTest/Run-Pester.ps1'
    ScriptArguments: '-ResourceGroupName "cloudboost-core-library-t" -TestFilePath "$(System.DefaultWorkingDirectory)\_pipelines\VSTS\PowerShellScripts\PesterTest\*.Tests.ps1" -SrcDirectory "$(System.DefaultWorkingDirectory)\_azure\ARM\$(folder)\" -OutputDirectory "$(Common.TestResultsDirectory)" -Username "$(ServicePrincipalUsername)" -Password "$(ServicePrincipalPassword)" -TenantId "$(TenantId)" -SubscriptionId "$(SubscriptionId)"'
    FailOnStandardError: true
    azurePowerShellVersion: LatestVersion

Example

_azure/.vsts-ci.yml has the examples which validates all templates in the _azure directory.

first task installs Pester in the build server than two pairs of the same test tasks. The first executes and publishes the generic Pester Test the second the specific Pester Test for that ARM template.

- powershell: |
   Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
   Install-Module -Name Pester -Force -Scope CurrentUser -SkipPublisherCheck
  displayName: 'Install Pester'

- task: AzurePowerShell@3
  displayName: 'Run Tests'
  inputs:
    azureSubscription: 'sogeti-core-cloudboostsite-p'
    ScriptPath: '_pipelines/VSTS/PowerShellScripts/PesterTest/Run-Pester.ps1'
    ScriptArguments: '-ResourceGroupName "cloudboost-core-library-t" -TestFilePath "$(System.DefaultWorkingDirectory)\_pipelines\VSTS\PowerShellScripts\PesterTest\*.Tests.ps1" -SrcDirectory "$(System.DefaultWorkingDirectory)\_azure\ARM\$(folder)\" -OutputDirectory "$(Common.TestResultsDirectory)" -Username "$(ServicePrincipalUsername)" -Password "$(ServicePrincipalPassword)" -TenantId "$(TenantId)" -SubscriptionId "$(SubscriptionId)"'
    FailOnStandardError: true
    azurePowerShellVersion: LatestVersion

- task: PublishTestResults@2
  displayName: 'Publish Test Results'
  inputs:
    testResultsFormat: NUnit
    testResultsFiles: '**\TEST-*.xml'
    searchFolder: '$(Common.TestResultsDirectory)'
    mergeTestResults: false
    testRunTitle: 'Test Results for ARM Templates'

- task: AzurePowerShell@3
  displayName: 'Run Tests'
  inputs:
    azureSubscription: 'sogeti-core-cloudboostsite-p'
    ScriptPath: '_pipelines/VSTS/PowerShellScripts/PesterTest/Run-Pester.ps1'
    ScriptArguments: '-ResourceGroupName "cloudboost-core-library-t" -TestFilePath "$(System.DefaultWorkingDirectory)\_azure\ARM\$(folder)\*.Tests.ps1" -SrcDirectory "$(System.DefaultWorkingDirectory)\_azure\ARM\$(folder)\" -OutputDirectory "$(Common.TestResultsDirectory)" -Username "$(ServicePrincipalUsername)" -Password "$(ServicePrincipalPassword)" -TenantId "$(TenantId)" -SubscriptionId "$(SubscriptionId)"'
    FailOnStandardError: true
    azurePowerShellVersion: LatestVersion

- task: PublishTestResults@2
  displayName: 'Publish Test Results'
  inputs:
    testResultsFormat: NUnit
    testResultsFiles: '**\TEST-*.xml'
    searchFolder: '$(Common.TestResultsDirectory)'
    mergeTestResults: false
    testRunTitle: 'Test Results for ARM Templates $(folder)'

Test results are collected during the Build.

PestersTestResults