Hands-On Lab

Lab Management Improvements in Visual Studio 2012

Lab version: 11.0.60315.01 Update 2

Last updated: 4/9/2013

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 18

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

Overview

In this lab, you will learn about some of the new features and improvements in lab management for Visual Studio 2012. 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 2012 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.

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 2012 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 2012 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 2012 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 can log in as Administrator – all user passwords are P2ssw0rd.

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. One 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 on the VSALM machine. All user passwords are P2ssw0rd.

2.  Launch the Test Controller Configuration Tool from Start | All Programs | Microsoft Visual Studio 2012.

Figure 1

Launching the Test Controller Configuration Tool

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 2

Test Controller Configuration

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

Figure 3

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 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 Start | All Programs | Microsoft Visual Studio 2012.

Figure 4

Launching Microsoft Test Manager

3.  Microsoft Test Manager will connect to the team project that was last in use on startup. Select the Home button in the upper-left corner to select a different project.

Figure 5

Location of home button

4.  Click on the Change Project link.

Figure 6

Changing the active project

5.  When you are prompted to connect to a team project, select the VSALM -> FabrikamFiberCollection -> FabrikamFiber node and then select the Connect Now button. When you are prompted to close all open items, go ahead and do so.

Figure 7

Connecting to a team project

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

Figure 8

Selecting a test plan

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

Figure 9

Navigating to the Lab Center in Microsoft Test Manager

8.  Select the New button in the Environments section.

Figure 10

Creating a new standard environment

9.  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 11

Creating a new standard environment

Note: In Visual Studio 2012, there is more support for virtual machine template features, which will be managed in SCVMM 2012, 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.

10.  Select the Add Machine button.

Figure 12

Adding a machine to the new standard environment

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

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

Figure 13

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.

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

Figure 14

Moving on to the Advanced environment setup step

14.  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 15

Configuring the test agent to run UI tests

15.  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 16

Verifying the new environment selections made

16.  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 17

Starting the process of standard environment creation

17.  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.

Figure 18

Status of standard environment creation

18.  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.

Figure 19

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

19.  Also, note that the environment is reported as being in the Ready state within Microsoft Test Manager (on VSALM). It can take a few 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 20

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 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 2012 from the shortcut on the taskbar or from Start | All Programs | Microsoft Visual Studio 2012.

Figure 21

Starting Visual Studio 2012

4.  Open the FabrikamFiber.CallCenter solution from the Dev branch in Source Control Explorer.

Figure 22

Source Control Explorer window

5.  Select Build | Build Solution from the main menu to build the solution. This will ensure that the coded UI test is available when picking automation for the existing test case.

6.  In Team Explorer – Home, select the New Query link.