In my previous post “Continuous Delivery using VSO Release Manager with Selenium Automated Tests on Azure Web Apps (PaaS)”, I’ve walked through the steps on how to enable continuous delivery by releasing builds to multiple environments. One caveat that I didn’t focus on is taking the same tests and running it against those target environments.
In this post, I’ll walk you through the steps on enabling or running the same tests targeting those environments that you have included as part of your continuous delivery pipeline. You’re basically taking the same tests however passing in different parameters such as the target URL and/or browser to run.
In a high level, these are the changes. The solution only requires:
· Create runsettings file and add your parameters.
· Modify your code to call the parameters from the .runsettings file
· Changes to the “Test Steps” in VSTS release or build
In Visual Studio, you have the ability to generate a “testsettings” file however not a “runsettings” file. What’s the difference between both file formats? Both can be used as a reference for executing tests. However the “runsettings” file is more optimized to be used for running Unit Tests. In this case our tests are unit tests.
For more information see: Configure unit tests by using a .runsettings file
1) Create an xml file with the extension of: .runsettings (e.g. ContinousDeliveryTests.runsettings)
2) Replace the contents of the file with the following:
3) Save the file to your source control repository. In my case GIT in VSTS.
Modify your code to call the params from the .runsettings file
In your unit tests where you specify the URL, apply the following changes:
At this point, you can refer the envUrl variable in your code for navigating through your tests.
Changes to the “Test Steps” in VSTS release or build
In VSTS Release Manager, modify the test steps to:
NOTE: As part of your build definition, ensure that you upload your runsettings file as part of your artifacts directory. Here’s a snippet in my build definition step:
Visual Studio Test step in Release Manager:
For each environment that you deploy your application, modify the Visual Studio Test Step to:
– Specify the runsettings file. You can browse through your build artifacts provided you’ve uploaded your runsettings file as part of your build artifacts
– Override the parameters with the correct value for your environment URL
One you make the following changes, your tests will execute targeting those environments specified in your continuous delivery pipeline.