Passing Input parameters from Azure Pipeline to Tests

In the last blog Test Automation Execution on Azure , we saw how to create Azure pipeline for executing Automation test scripts on Azure. These pipelines can be used to execute scripts on multiple environments like Development, QA, UAT etc. For this, the scripts need to have some generic variables like for web applications the URL will be different for different environments or the login credentials can differ.To cater to this, input parameters can be passed from Azure pipeline tasks to tests by overriding variable used in runsettings file.

Consider following example to supply input parameters from Azure pipeline to tests:

  • Add a new xml file to your Automation Project and save it with .runsettings extension.
  • Now, configure the elements in the runsettings file as shown below.
  • This value can then be used in tests using TestContext.Properties if you are using MSTest framework and if you using NUnit Framework , then can be used using TestContext.Parameters.

  • Now, configure the runsettings file as shown below and build the solution and check in the runsettings file in your code repository.

  • Now, Go to your Azure pipeline, edit your already created pipeline and go to Variables section and create a new variable there for the element you configured in runsettings file and click save.
  • Click on Tasks and edit the Visual Studio Test Task. Browse for settings file under Settings File header. In Override test run parameters, provide the value of parameter in the format : -<VariableNameinRunsettings> $<VariableNameUnderVariableSection> and click on Save & Queue.
  • Automation Scripts will start executing using values provided in the Variable section.

Design a site like this with WordPress.com
Get started