Export (0) Print
Expand All

How to: Run Automated Tests Using Virtual Environments

Visual Studio 2010

You can use Microsoft Test Manager to run automated tests by using virtual environments that you have created by using Lab Management. You must associate the automated test with a test case. Then you can add the test case into a test suite that is part of a test plan. You can also run these tests from the command line by using tcm.exe. The results can then be viewed as part of your test plan results.

Running automated tests by using virtual environments is the same process as running automated tests by using Microsoft Test Manager with physical environments. The following procedures describe the prerequisites for virtual environments to let you run your automated tests. You can connect to the virtual environment after you have run your tests.

Note   We do not recommend that you use virtual environments to run load or stress tests.

Before you can run automated tests by using your environment, you must follow these steps:

  • Create a virtual machine or template for each role that is required in your virtual environment.

  • Install a lab agent and test agent on each virtual machine so that you can run automated tests and collect data and diagnostics on each machine when you run your tests.

  • If you are running tests that interact with the desktop, and want to use virtual machines for the role to run tests, you must configure the test agent to run as an interactive process. For more information, see How to: Set Up Your Test Agent to Run Tests that Interact with the Desktop.

  • If you want to deploy your application by using the workflow integration capability, you must also install build agents on the virtual machines.

  • Install a test controller that you can use for your virtual environment. For more information about this, see How to: Add Test Controllers to Use for Testing with Lab Management.

  • You must associate your automated tests with test cases and add them to a test suite in a test plan. For more information, see How to: Associate an Automated Test with a Test Case or How to: Create Test Cases from an Assembly of Automated Tests Using tcm.exe.

To run automated tests using a virtual environment

  1. Create a virtual environment and add the necessary virtual machines or templates for each role. For more information, see Virtual Environments Concepts and Guidelines and How to: Create an Environment from Virtual Machines or Templates.


    You must enable the testing capability in the virtual environment. You must select a test controller to use for this capability.

  2. To start the virtual environment, select the environment from the Environments view and click Start.


    If the environment that you want to use has been stored in the library, you must deploy the environment to create the virtual machines from the stored images before you can start the environment.

  3. Verify that the machines in your environment have started and that the test capability is enabled. In the Environments view, the status of the testing capability is displayed next to Testing in the details for the environment.


    If you are running tests that interact with the desktop, you must log on to the virtual machine that is used as the role to run tests in your environment to start the interactive process for the test agent. Until you log on to the machine, the testing capability is not enabled.

  4. (Recommended) To prevent other users from accidentally connecting to your environment when you run your tests, click the drop-down arrow next to Mark 'In Use' in the toolbar. Add a comment about who is using the environment and click Mark 'In Use'.

    If another user tries to connect to the environment that is being used, a warning with the comments that you entered is displayed in the Connect to environment dialog box.


    You can also mark an environment In Use from the Microsoft Environment Viewer.

  5. Install your application on the virtual machines in your environment. You can use the workflow capability to do this automatically by using a build definition. For more information about how to do this, see How to: Deploy an Application on a Virtual Environment. Or, you can install the application manually.


    We recommend that you take a snapshot of each virtual machine after you install your application so that you can easily return to this clean state with the application installed.

  6. To run your automated tests, use the procedures in How to: Run Automated Tests from a Test Plan Using Microsoft Test Manager to perform the following tasks:

    1. Assign a build to your test plan to use to locate the test assembly.

    2. Create test settings that contain the set of roles for your virtual environment and assign these test settings and your environment to your test plan.

    3. Run your automated tests

    4. View the results


    If you are running tests that interact with the desktop, you can see each test as it runs if you connect to the environment from the Environments view on the virtual machine for the role to run tests. If you are an administrator, you can also see the tests as they run in the thumbnail view of the virtual machine.

  7. To investigate any test results, you can connect to any one of the virtual machines in the environment. To do this, right-click the machine in the Environments view and point to Connect.

    The Microsoft Environment Viewer is displayed.

    For more information about how to connect to a virtual environment, see How to: Connect to a Virtual Environment.

    If you are using an environment with network isolation enabled, see How to: Connect to Virtual Machines in an Environment that Uses Network Isolation.

Community Additions

© 2014 Microsoft