Steps:
- Intro
- VSO
- Docker
- xUnit
- Build
- Back end
- Selenium
- Docker
- Release Management
- Testing
This is the final post in the series on how I built my demo for Ignite New Zealand 2015. In this post we are going to add tests to our release definition. We are going to run Selenium and cloud-based web performance tests.
I feel the most interesting part is how we only have to write the Selenium test once but we are able to run it against and URL we like. We are going to pass in at runtime the URL we want the test to exercise. This is all controlled by a .runsettings file. Values we set in the runsettings file can be accessed by the test. We can override those values using the Visual Studio Test task in build and release.
The first thing we need to do is add a .runsettings file to your project. When we originally added the test, it was already written to use the values in the .runsettings file.
- Add .runsettings file
- Open PeopleTrackerWebService solution
- Right click on PeopleTracker.UITests
- Select Add / New Item…
- Select XML File and name it bvt.runsettings
- Replace the contents of the file with the code below
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<TestRunParameters>
<Parameter name="webAppUrl" value="http://localhost:50235/" />
<Parameter name="browser" value="ie" />
</TestRunParameters>
</RunSettings>
- Right-click on bvt.runsettings and select Properties
- Change Copy to Output Directory to Copy Always
- Commit and Push your changes
I set the values to my development environment settings. We are going to pass in the URLs for our ASP.NET 5 applications running in their Docker hosts during our release. I also wanted to control the browser used during the test execution. The value for browser needs to match one of the values in the MyTestInitialize method in our test class.
With the .runsettings file in place we can return to our release definition and add our test tasks.
- Edit your release definition
- Select the Dev environment
- Click Add tasks
- Add the Visual Studio Test task from the Test section
- Click the Visual Studio Test task
- Set Test Filter criteria to
TestCategory=UI
- Browse to the bvt.runsettings file
- Set Override TestRun Parameters to
- webAppUrl=[URL to Dev Docker Host]/;browser=firefox
Make sure that whatever browser you select is actually installed on your agent or you will get an error during your release.
Repeat adding this task to the QA environment updating the webAppUrl to QA host and browser to Chrome.
Now we are going to add cloud-based web performance test . To use the cloud-based web performance test task, we have to first create a Personal Access Token.
- Create Personal Access Token
- From the upper right-hand corner, click your name and select My Profile
- Select the Security tab
- Click Add under Personal access tokens
- Give the access token a name
- Select how long you want the token to be valid
- Select the accounts you want to be able to access this token with
- Leave All scopes selected
- Click Create Token
- Copy the token value
You can now return to your release to add the cloud-based web performance test task with your new Service Endpoint.
- Configure QA environment
- Select the QA environment
- Click Add tasks
- Add the Cloud-based Web Performance Test from the test section
- Click Manage next to Registered connection
- From the New Service Endpoint menu select Generic
- Enter Web Performance Test for the Connection Name
- Enter your VSTS url for the Server URL
- https://[yourAccount].visualstudio.com
- Enter your VSTS user name
- Paste your Personal Access Token into the Password/Token Key textbox
- Click OK
- Return to your release definition and click the refresh button next to Registered connection
- Select the connection we just created
- Enter your Docker host FQDN for Website URL
- Enter a name for the Test Name
- Save and start a release
When your release runs, it will run a Selenium test and a cloud-based web performance test. The results of your Selenium test will be shown in the Release Summary under Test Results.
However, to see the results of your Web Performance Test, we have to visit the Load test hub.
I hope you enjoyed learning about the power of the DevOps offering from Microsoft with this series. These tools can be used to build and deploy any language to any platform.
Now I will start working on my 2016 demo where I will add more operations-focused processes such as Infrastructure as Code and Application Insights.