Hands-On Lab

Lab Management using Standard Lab Environments in Visual Studio 2013

Lab version: 12.0.30723.00 Update 3

Last updated: 8/1/2014

Contents

Overview 3

Exercise 1: Preparing a Test Agent Machine 4

Exercise 2: Configuring the Test Controller 5

Exercise 3: Creating a Standard Environment 7

Exercise 4: Preparing for Automated Testing 16

Exercise 5: Creating and Running a Build-Deploy-Test Definition 24

Overview

In this lab, you will learn about some of the new features and improvements in lab management made in recent versions of Visual Studio. This includes the creation of standard environments, which allows existing test environments to be added into Lab Management, with no infrastructure prerequisites and no configuration needed in Team Foundation Server. In addition, there is no longer a need to spend much time with the test agents, as there is only one test agent type and the agents are automatically installed on the test environments. After completing this lab, you will have a good idea how easily and quickly you can now get a build, deploy, and test workflow setup using your existing development environment.

Prerequisites

In order to complete this lab you will need the Visual Studio 2013 virtual machine provided by Microsoft. For more information on acquiring and using this virtual machine, please see this blog post.

About the Fabrikam Fiber Scenario

This set of hands-on-labs uses a fictional company, Fabrikam Fiber, as a backdrop to the scenarios you are learning about. Fabrikam Fiber provides cable television and related services to the United States. They are growing rapidly and have embraced Windows Azure to scale their customer-facing web site directly to end-users to allow them to self-service tickets and track technicians. They also use an on-premises ASP.NET MVC application for their customer service representatives to administer customer orders.

In this set of hands-on labs, you will take part in a number of scenarios that involve the development and testing team at Fabrikam Fiber. The team, which consists of 8-10 people, has decided to use Visual Studio application lifecycle management tools to manage their source code, run their builds, test their web sites, and plan and track the project.

Change log

For Update 3:

·  Screenshot updates as necessary, other minor edits

Exercises

This hands-on lab includes the following exercises:

1.  Preparing a Test Agent Machine

2.  Configuring the Test Controller

3.  Creating a Standard Environment

4.  Preparing for Automated Testing

5.  Creating and Running a Build-Deploy-Test Definition

Estimated time to complete this lab: 60 minutes.

Exercise 1: Preparing a Test Agent Machine

In this preparatory exercise, we will create and configure the second virtual machine that will be used later on in this lab. To minimize the size of the download, we will create and use another instance of the Visual Studio 2013 virtual machine as a test agent machine.

Note: The instructions provided in this section apply to Hyper-V running in Windows Server 2008 R2 SP1, but the overall steps generally apply to Windows 8 Hyper-V as well.

1.  At this point, you should already have an instance of the Visual Studio 2013 virtual machine setup after following the Prerequisites section of this document. Perform this setup step if not already completed.

2.  In Hyper-V Manager, create a snapshot of the working virtual machine and name it something like “Visual Studio 2013 Base”.

3.  Right-click on the base snapshot and select the Export option.

4.  In the Export Virtual Machine dialog, choose a location that has space and that is on a different physical disk (if possible).

5.  Click the Export button to start the export process. This will take a few minutes to complete.

6.  After the export is complete, click the Import Virtual Machine button within Hyper-V Manager.

7.  Select the location of the recent export and make sure to select the “Copy the virtual machine (create a new unique ID)” option under import settings.

8.  Boot the first instance of the virtual machine (machine name is VSALM).

9.  Boot the second instance of the virtual machine and execute the ConfigureVSALM2.bat file found in c:\util to change the machine name to VSALM2 and perform other necessary configuration. You will need to right-click on the script and run it as an administrator.

10.  Reboot the newly minted VSALM2 machine so that the new name takes effect.

11.  Ensure that the two virtual machines can communicate with each other. The recommended way to do this is to ensure that they are both configured to use an Internal Only virtual network adapter and are configured to both be on the same VLAN.

12.  Log into VSALM2 and ensure that you can ping the VSALM machine by loading a command prompt window and entering “ping -4 VSALM”. If this is a success, you are ready to continue with the lab.

13.  Take a snapshot of the VSALM2 virtual machine so that you can reset the lab later (if desired).

Exercise 2: Configuring the Test Controller

In this exercise, you will learn how to configure the Test Controller. The Test Controller software has already been installed and configured on the virtual machine, so we will just take a quick look at it.

1.  Log in as Adam (VSALM\Adam) on the VSALM machine. All user passwords are P2ssw0rd.

2.  Launch the Test Controller Configuration Tool. The easiest way to do this is to start typing “Test Controller…” while on the start screen.

3.  In the Configure Test Controller window, note that test controller is already registered with a team project and that a lab service account is specified. Registering with a team project collection will enable us to create a virtual environment to run automated tests against later on in the lab. If you just wanted to run tests from Visual Studio, you would instead keep the test controller unregistered.

Figure 1

Test Controller Configuration

4.  Click the Close button and exit without applying the settings.

Figure 2

Exiting test controller configuration without changes

Note: If you would like to make changes to the test controller configuration for purposes outside of this lab, execute the ConfigureTestController.bat script found in the c:\util folder in the virtual machine. We have some non-standard modifications in place so that demo URLs will resolve correctly (such as http://www.fabrikam.com), and this script temporarily disables these modifications so that the test controller can properly finish configuration.

Exercise 3: Creating a Standard Environment

In this exercise, you will learn how easy it is to create a standard environment to use with your automated testing scenarios. Note that it really does not matter if this is a real machine or a virtual machine, running on Hyper-V or VMware, as long as you can connect to it you can use it for your testing.

1.  Log in as Adam (VSALM\Adam) on the VSALM machine. This is where we will initiate the creation of the standard environment using Microsoft Test Manager. The environment itself, once installed and configured, will run on the VSALM2 machine.

2.  Launch Microsoft Test Manager from the taskbar.

3.  Connect to the FabrikamFiber team project. You may need to click on the Home button followed by the Change Project button if you are automatically connected to a test plan.

Figure 3

Connecting to the FabrikamFiber team project

4.  Select the Default test plan and then select the Select Plan button to continue.

Figure 4

Selecting a test plan

5.  In Microsoft Test Manager, select the drop-down arrow just to the right of the Testing Center and select Lab Center.

Figure 5

Navigating to the Lab Center in Microsoft Test Manager

6.  Select the New button in the Environments section.

Figure 6

Creating a new standard environment

7.  In our case, we will create a new standard environment, which means that we will use an existing machine that is already setup and ready for testing. For the name of the new environment, enter “Fabrikam BDT” which stands for Build-Deploy-Test and then select the Next button to continue.

Figure 7

Creating a new standard environment

Note: Recent versions of Visual Studio have introduced more support for virtual machine template features, which will be managed in SCVMM, rather than in Lab Manager. There is also better separation of concerns between Team Foundation Server admins and SCVMM admins, as the TFS service account no longer has to be an administrator on all hosts.

8.  Select the Add Machine button.

Figure 8

Adding a machine to the new standard environment

9.  We will use the duplicated virtual machine here, so type “VSALM2” for the computer name and then select the Web Server role.

10.  Enter “.\Adam” for the user name and “P2ssw0rd” for the password.

Figure 9

Adding a machine to the new standard environment

Note: You could add more machines to the environment if needed to fill different roles for testing, such as database server, domain controller, etc.

11.  Select the Advanced step on the left-hand side.

Figure 10

Moving on to the Advanced environment setup step

12.  Here we can select the test controller to associate with this new environment and optionally configure it to run UI tests. Select the “Configure environment to run UI tests” checkbox, select the Web Server role, and go ahead and specify that the Adam account will be used for running the test agent.

Figure 11

Configuring the test agent to run UI tests

13.  Select the Verify button to verify the selections that you made for the new standard environment. As you wait, note that the wizard ensures that the test controller is available, that the machines and credentials you provided will work, and that the machine is not already part of another environment.

Figure 12

Verifying the new environment selections made

14.  After the verification step passes, select the Finish button to start the process of installing the test agent in the environment. Note that the test agent installation and configuration proceeds automatically.

Note: The Test Agent installation and configuration is taken care of for you, whereas with previous versions you had to do this yourself. It will take a few minutes for the test agent to install and for the new standard environment to be ready for use. As the test agent is installed, the VM will automatically restart if necessary.

Figure 13

Starting the process of standard environment creation

15.  As you wait for the test agent to be installed and configured, note that the status of the installation goes through a number of states to keep you informed of progress. This step will take some time to complete, so this is a great place to take a break and get another coffee ready.

Figure 14

Status of standard environment creation

16.  As part of the standard environment setup and installation of the test agent on VSALM2, that virtual machine will restart and automatically log in with the Adam user account. It will take a few minutes for this process to complete, but once it is done, you should see the Test Agent Status window appear on the test agent machine and report an Online status (you will need to manually load the desktop if you are looking at the start screen).

Figure 15

Test Agent Status screen running on test agent machine (VSALM2)

17.  Also, note that the environment is reported as being in the Ready state within Microsoft Test Manager (on VSALM). It can take a few additional minutes for the test controller machine to report the Ready state even after the test agent machine reports that it is online. We are now ready to create an automated Build-Deploy-Test workflow.

Figure 16

Microsoft Test Manager showing the environment as ‘Ready’

Exercise 4: Preparing for Automated Testing

In this exercise, you will use an existing coded UI test to automate an existing test case and create test settings to indicate that we would like to use the new standard environment to perform automated tests.

1.  Log in as Adam (VSALM\Adam) on the VSALM machine.

2.  Let’s say that we already have a test case in place that has been used by the Fabrikam Fiber team for manual testing, and that it has an action recording associated with it. In addition, the team has created a coded UI test based on that action recording that allows them to kick off an automated test at any time in their development environment. Let’s take this existing groundwork and use it to automate tests in an external test environment.

3.  Launch Visual Studio 2013 from the taskbar and open Team Explorer. You should now be connected to the FabrikamFiber team project. If you are not automatically connected to the FabrikamFiber project, select the Connect to Team Projects button () to do so.

Figure 17

Connecting to Team Explorer – Home

4.  In Team Explorer – Home, double-click on the first FabrikamFiber.CallCenter.sln solution.

Figure 18

Loading Fabrikam Fiber solution

5.  Open CodedUITest1.cs from the FabrikamFiber.Web.UITests project and un-comment the CodedUITest attribute from the top of the CodedUITest1 class definition.