Careers   |   Events   |   Contact   |   402.238.1399   |   contactus@deliveron.com

Deliveron
Connect with us on FacebookConnect with us on LinkedInFollow Us on Twitter

Category List


Tag List

MVP (2)
Keith Holt (1)
Mike Douglas (4)
database projects (4)
Collaboration (2)
workflow (2)
business intelligence (2)
service-fabric (1)
lunch and learn (2)
artifacts (1)
ARM Template (1)
asp.net-mvc-3 (4)
nintex (4)
automatedui (1)
sql server (2)
asp.net-mvc-4 (2)
testing (5)
single page applicaiton (1)
Infrastructure (1)
azure mobile services (2)
Node.js (1)
user profiles (4)
Functions (2)
gherkin (2)
razor (4)
whitelist (1)
certificates (2)
nebraska code camp (2)
team build (2)
dependency-injection (2)
TestArchitect (5)
REST (1)
bundling (2)
visual studio code (1)
pdf (2)
sharepoint (5)
webs (2)
scrum (8)
selinium (1)
subsites (2)
feedback (2)
load testing (2)
ninject (2)
Web API (1)
security (1)
react (1)
PBI (1)
association (1)
javascript (3)
DevSecOps (2)
Analytics (2)
event-handling (2)
top 5 (1)
tfs 2012 (4)
tfs 2013 (2)
sql saturday (2)
preview (1)
microsoft case study (2)
microsoft alm rangers (2)
visual studio team services (1)
AzureAD Admins (1)
fluentvalidation (2)
site collections (2)
microsoft test manager (2)
swagger (1)
ssas (2)
Document (1)
angular (1)
cascading-dropdown (2)
test automation (1)
Multi-Factor Authentication (1)
lab environments (1)
whitesource (1)
tfs (11)
DevOps (14)
test controller (2)
Visual Studio Online (6)
Visual Studio 2017 (4)
bi (2)
pipelines (1)
opensource (1)
2013 (2)
windows azure (2)
adfs (3)
wit (2)
installation (2)
burndown (2)
lab management 2010 (2)
team foundation server 11 beta (2)
planning poker (4)
insiders (1)
OAuth2 (1)
application insights (2)
tfs 2010 (2)
coded ui tests (6)
tags (2)
msi (2)
visual studio 2010 (18)
alerts (2)
selenium (4)
test cases (2)
webpack (1)
API Tests (1)
pipeline (1)
team deploy (2)
Data Analytics (1)
IntelliSense (1)
sharepoint 2013 (6)
Java (1)
Power BI (3)
Big Data (2)
web (1)
tfs 2017 (1)
dns (2)
tips (2)
spc14 (4)
vsdbcmd (2)
json (2)
AzureAD (1)
Meetings (1)
MFA (1)
TFS 2015 (6)
deployment (2)
Nuget (1)
mvvm (2)
Build (6)
sharepoint 2007 (2)
code-first (4)
powershell 2.0 (8)
continuous inegration (2)
M Query (1)
CI (3)
Office 365 (1)
Azure (14)
web performance tests (2)
Template (1)
HOLs (1)
fields (2)
webcast (4)
table-valued-parameters (4)
database publishing wizard (2)
visual studio 11 beta (2)
zap (1)
owasp (3)
onenote (4)
team foundation 2012 (2)
kanban (1)
test agent (2)
web application firewall (1)
angular 2 (3)
team foundation server (6)
sharepoint 2010 (10)
performance (3)
AAD (2)
c# (13)
web deploy (1)
alm (9)
Cosmos DB (1)
example (2)
bdd (2)
my work (2)
lync (2)
mstestv2 (1)
data warehousing (2)
tfs odata (2)
webparts (2)
reporting (2)
gulp (2)
work item (2)
tls 1.2 (1)
outlook (2)
necc (2)
dbpro (2)
visual studio 2012 (10)
asp.net-mvc-routing (2)
Business (2)
wiki (1)
storyboarding (2)
power tools (2)
business insight (2)
nunit (1)
team web access (2)
agile (12)
exchange (2)
deliveron agile delivery process (2)
Powershell (1)
home projects (1)
rest assured (1)
Quality (2)
ssl (1)
Automated Testing (10)
video (2)
silverlight (2)
Decisions (2)
azure resource manager (1)
vsts (22)
xaml (2)
entity-framework (6)
release management (7)
visual studio (8)
load tests (2)
action-filters (2)
connect() (1)
windows 8 store app (2)
team foundation server 2012 (4)
jquery (4)
sql server 2008 (2)
continuous integration (2)
performancepoint services (2)
licensing (2)
netstandard (2)
ssrs (4)
tokenization (1)
Azure Functions (1)
alm rangers (1)
faq (2)
deliveron alm delivery guidance (2)
github (1)
sp1 (2)
asp.net-mvc (6)
serverless (3)
MSBuild (1)
requirements (2)
xunit (1)

Archive

Configuring UI Test Agents using the Visual Studio Test task in VSTS

Mar 05, 2018

A little more than a year ago I wrote an article on running cross browser UI Tests for the MVP Award Blog titled Running Cross Browser Automated Tests in Visual Studio Team Services.  Like other technologies in our fast changing world, these tasks have now been deprecated.  Fortunately it has been replaced by a new approach that should help address some challenges to using the older way I described in the article. 

In this post, I will show how to convert or set up a new release that can execute UI tests using the new approach.  I will focus on the initial setup of one agent and discuss more of the advanced features like scaling it out in next post.  As with any new tools, there are some features that are better in the new process but also some things that are they are still working on.  I'll go through these and touch on a couple issues I ran into to help you get through it more quickly.

If you have set up a release in VSTS to execute UI tests in the past and you have viewed the release definition recently, you have probably noticed that that the Run Functional Tests and Visual Studio Test Agent Deployment tasks have been marked deprecated like the picture above shows.  Let's walk through what has changed and how we can accomplish the same functionality with the new process.

depreciated_run_functional_tests_task.jpg

With the previous way of doing this, the one of the biggest challenges was getting the build agents to communicate with the test agent machines.  This used WinRM and it was difficult to get the communication working especially working in non-domain environments such as Azure VMs that are not domain joined.  The other challenge is that the DLL(s) containing the tests are on the build agent but the test agents need them to execute the tests.  This required a copy task to get the files to the machines.  Again, doing this across a non-domain machines in Azure can be difficult.

The new way uses the build agent as a unified agent for executing builds, releases, and test execution.  It makes sense since some tests such as unit tests have are already been running on the build agent.  This also simplifies the two challenges we described.  Since this is a build agent, the artifacts including the test DLL(s) are automatically downloaded so this doesn't require the copy files task.  Also, by using the build agent, the communication to execute and report the test results back to VSTS is local to the agent removing that complexity.

Azure Virtual Machine (VM) Set Up

As with the previous approach, the test agents do not require having Visual Studio installed.  However, if you choose not to install Visual Studio or the test tools manually, you will need to use the Visual Studio Tools Platform Installer task.  This will ensure that the testing tools are on the agent machine before the tests execute.  Be sure to do the usual Agent VM preparation and install any required browsers and disable things like auto form filling out and remembering passwords.

The next step is to install the Build Agent on the VM.  To install the Agent, follow the directions to Deploy an Agent on Windows.  The important part is that the agent needs to be installed by choosing interactive with auto-logon so it can execute the automated UI tests.  Use the following settings to configure the agent properly.  At the end it will ask you if you want the VM to restart. You will want to do this to prepare the machine to run the tests.

interactive_agent_configuration.jpg

Remember if you connect to the VM via RDP for any reason including troubleshooting tests (which I often do), be sure to either reboot or use tscon command, %windir%\System32\tscon.exe 1 /dest:console on the machine to get it back to a good state before executing the tests.  With this new approach, the tasks and build agent do not have the ability to self heal and reboot to get back into a good state like the previous task was able to do.  This is still something Microsoft is still working on.  However, refer to the process I outline below to only start the VMs before the test run to always ensure they are in a good state

Optionally, your UI Tests may require a certain resolution when executing.  Azure and other VMs typically use a low resolution when the machine is auto-logging that is different than when you specify the resolution in RDP (remote desktop).  I created a free, small utility to change the screen resolution can easily be installed in two steps.  The first is to install Chocolatey, a windows package management tool and the second installs the tool to run on startup.  This will set the resolution to 1920 x 1080 up start and auto-logon of the VM.

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

choco install change-screen-resolution  --params "'/RunAtStartup:true'"

Release Definition Creation

Before creating the release definition, create a CI build that compiles your automated UI tests project.  If you don't have one, you can use my github project as the source.  This has a handful of Selenium UI tests.

The Visual Studio Test task is the primary task that will execute the tests.  To run tests on an agent machine without Visual Studio, use the Install VsTest Platform task before the task above.

visual_studio_test_tasks.jpg

 

Most of the settings are straight forward. However, when initially executing the task, I received this error:

Error: Visual Studio 2015 is not found. Try again with a version that exists on your build agent machine.

I noticed that the test platform version was set to latest by default.  I changed it to Installed by Tools Installer and it fixed the issue.

installed_by_tools_installer.jpg

One other key setting is to specify that the test mix contains UI tests.  This setting doesn't automatically configure the agent to run interactively as this has to be done as part of the agent configuration.

contains_ui_tests.jpg

In my article from last year, one of the key benefits of using Azure VMs for the test agents is that the agents can but shut down when not in use and save a lot of money.  We can accomplish the same ability to shut down the VMs when not in use with the new approach.  Below is the release definition configured to accomplish this.

While the Hosted Agents can't be used to execute the tests, we can configure the release with multiple phases and choose the Hosted Agents for the starting and stopping of the agents while using our UI Test Agent for the test execution.  The Azure Resource Group Deployment task has an option to start and shutdown all VMs in a resource group.   Be sure to create Test Agents you want grouped together in the same Azure resource group.  Additionally, the VM shutdown has two options. One that deallocates the VM and the other that doesn't.  You must use the deallocate option to stop incurring cost.

test_environment_execute_uitests.jpg

The VM start/shutdown adds about 3 to 4 minutes to the release which isn't bad considering as you add more tests, they could run for over an hour.  Starting and stopping of the VMs should happen in parallel if you have multiple machines so it shouldn't slow down as you scale this out.

This article showed you how to configure a single Test Agent using the new Visual Studio Test task replacing the deprecated Run Functional Tests task.  In the next article, I'll walk through scaling this out to include test run resiliency and how to support cross browser test runs.

As always, feel free to comment or ask any questions on Twitter at @mikedouglasdev



Category: DevOps

Mike Douglas

user_avatar

He is a solution consultant focused on helping organization build high quality application effectively utilizing DevOps practices. He is a Microsoft DevOps / ALM Ranger and you can reach him on Twitter at @mikedouglasdev


We believe in helping our customers create software solutions in a better way.
We do this by having a project delivery process and technology expertise that ensures we are solving the right problem in the right way and driving the most business value.