How to: Run Automated Tests Using Virtual Environments

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.

Prerequisites

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

Procedures

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.

    Note

    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.

    Note

    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.

    Note

    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.

    Note

    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.

    Note

    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

    Note

    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.

See Also

Concepts

Testing Using Virtual Environments

Using a Virtual Lab for Your Application Lifecycle

Running Automated Tests