Running Automated Tests
After you have created any one of the following types of automated tests by using Microsoft Visual Studio 2010, you can then run the tests.
Coded UI tests.
Database unit tests.
Many methods of running your automated tests are available, depending on how you want to run tests and view the results. If you run your automated tests by using a test plan, you can view your testing progress and easily rerun your tests as required. To run your automated tests by using a test plan, you associate your automated tests with test cases and run these test cases by using Microsoft Test Manager. To run your automated tests in this manner, you must create a physical or virtual environment to use when you run your tests. For more information about how to create virtual environments to use to run your tests, see Using a Virtual Lab for Your Application Lifecycle.
It is not a good idea to run load tests by using Microsoft Test Manager because you cannot view the test as it runs. It is useful to be able to do this for load tests.
The environment enables you to run tests, gather data, or perform system actions on machines for each specific role that you add to the environment. A role specifies the purpose of a machine in the environment. For example, a specific role could be called "Web Site for Customer Data Store." A machine can be a physical computer or a virtual machine. You select which machines to use in an environment for each role.
For example, you could run your tests on one machine and gather system information about a machine that runs the Web server for your application. Alternatively, you could run your tests on an environment that uses multiple machines and collect test impact data on those machines. In addition, you can also perform network emulation on the machine that runs the Web server for your application.
The following illustration shows three examples of scenarios for how you can set your test settings to run your tests by using environments from Microsoft Test Manager.
This method of running automated tests lets you view the overall status of any tests in your test plan. You can view the results of both manual and automated tests together, if you want. You can also run these test cases by using associated automation from the command line.
You can also run your tests directly from Microsoft Visual Studio 2010 or the command line without being part of a test plan or without using an environment to run them remotely. In addition, if you add your automated tests to a test category or a test list, your automated tests can be run automatically as part of the build process.
To take advantage of the multiple processors in a multiprocessor machine, you must run your tests by using test agent controllers and test agents. Otherwise, if you run your tests locally, you will not use this additional processing power. For more information, see Setting Up Test Machines to Run Tests or Collect Data.
To run database unit tests, additional runtime assemblies are required. These assemblies are available only in the following SKUs:
Visual Studio 2010 Ultimate
Visual Studio 2010 Premium
Visual Studio Professional
Based on the following ways that you can run database unit tests, you may have to install one of these SKUs on additional machines:
If you run database unit tests locally by using Visual Studio, you must install one of these SKUs locally.
If you run database unit tests by using a test controller and test agents from Visual Studio, you must install one of these SKUs on any test agent computer that can be used to run these tests.
If you associate your database unit tests with a test case and run these tests from Microsoft Test Manager, you must install one of these SKUs on any test agent in your environment that is included in the role to run tests. You must also install one of these SKUs on the test controller for this environment.
Use the following topics to help you run automated tests.
Running automated tests remotely as part of a test plan: You can run automated tests as part of a test plan if you associate your automated tests with test cases.
Running automated tests locally or remotely from Microsoft Visual Studio: You can run automated tests locally from Microsoft Visual Studio 2010. Or you can run your automated tests remotely by using test agent controllers and test agents.
Running automated tests from the command line: You can run automated tests locally from the command line by using mstest.exe. Or you can run your automated tests remotely from the command line by using test agent controllers and test agents. Or you can run your automated tests that are associated with test cases from the command line.
Scheduling automated tests to run as part of the build process: You can use a test category to select the automated tests in your build definition that you want to run if the build is successful. The test results are reported as part of the build status when a build finishes.
If you have Visual Studio Lab Management, you can run automated tests that are associated with a test case and that are part of a test plan by using a virtual environment to deploy the application and run the tests.
You can also run tests to isolate stress and load issues by using load and Web performance tests.