Can the test configuration file be parameterized?

108 Views Asked by At

Is it possible to pass parameters to loadTestConfigFile? I want to have parameters for TestId and DisplayName in the config file so that I can use it for different environments and stages. This way the testId won't change and all runs of one environment will be within one testId. Is this possible?

1

There are 1 best solutions below

3
On

The TestId and DisplayName can be specified directly in Load Test config file(yaml). enter image description here

If you still would like to have parameters for them, you can use task Replace Tokens in DevOps pipeline before the loadtest task.

Sample to change testId:

step1: Change the testId value in config yaml.

enter image description here

  1. Add variable SampleTest in pipeline:

enter image description here

  1. Add replace token task before loadtest task:
    - task: replacetokens@5
      inputs:
        targetFiles: '**/SampleApp.yaml'
        encoding: 'auto'
        tokenPattern: 'default'
        writeBOM: true
        actionOnMissing: 'warn'
        keepToken: false
        actionOnNoFiles: 'continue'
        enableTransforms: false
        enableRecursion: false
        useLegacyPattern: false
        enableTelemetry: true

    - task: AzureLoadTest@1
      inputs:
        azureSubscription: $(serviceConnection)
        loadTestConfigFile: 'SampleApp.yaml'
        resourceGroup: $(loadTestResourceGroup)
        loadTestResource: $(loadTestResource)
        env: |
          [
            {
            "name": "webapp",
            "value": "$(webAppName).azurewebsites.net"
            }
          ]
          
    - publish: $(System.DefaultWorkingDirectory)/loadTest
      artifact: results
  1. Check in Azure portal:

enter image description here