Test Deployment Overview

Visual Studio Team Edition for Testers runs tests not in the folder in which you have created or generated them, but in a separate deployment folder. This separation helps ensure a cleaner test run and therefore, more accurate test results. In this deployment step, Team Edition for Testers copies deployment items, that is, files and folders, to the deployment folder before it runs tests. Team Edition for Testers copies files of the following types:

  • The test binary file, for example, the assembly built from your test project, or a generic test's binary file.

  • All dependent assemblies. For more information, see Troubleshooting in Team Edition for Testers.

  • Files you have specified, such as XML files and configuration files, on which tests depend. You can configure deployment both by specifying additional deployment items to be copied and by changing the deployment folder. For more information, see How to: Configure Test Deployment.

For more information about all the steps performed when tests are run, including the deployment step, see Steps in a Test Run.

Two Deployment Cases

There are two kinds of deployment, local and remote.

  • Local test runs. By default, tests are run locally on the same computer as your installation of Visual Studio. In this case, the deployment items and test binaries are copied into the local deployment folder and run there. For more information, see Local Deployment Folders.

  • Remote test runs. Remote runs involve the use of agents and controllers. First, deployment items are copied to the local deployment folder, specifically the [Out] folder for the current test run; see Local Deployment Folders. Then they are copied to the deployment folder on the controller computer, and from there they are copied to the deployment folder on one or more agent computers. Finally, the tests are run on the agent computers and the results are returned. For more information about agents and controllers, see Working with Controllers, Agents, and Rigs.

Local Deployment Folders

When you run the tests of a solution, Visual Studio creates deployment files under a folder called TestResults with the solution hierarchy. If the TestResults folder does not exist, Visual Studio creates it.

Note

If you are using the Visual Studio IDE, this folder is created directly under the solution folder; if you are not using the Visual Studio IDE, the TestResults folder is created under the current folder.

Each time you start a test run, Team Edition for Testers creates, under the TestResults folder, a set of folders to be used exclusively for that test run. The top folder in this set is named after the test run. In the example shown in the following illustration, the first folder under TestResults is "<user name>@<computer name><date> <time>", which is named after the "<user name>@<computer name><date> <time>" test run.

Local Deployment Folder for Tests

Deployment folders for a local test run

As shown in the preceding illustration, the solution ClassLibrary1 contains two projects, ClassLibary1 and TestProject1. Because tests have been run, this solution also contains a folder called TestResults. The TestResults folder contains one test results file for each test run. This test results file is named after the test run and has the extension .trx.

Other folders are created under the TestResults folder, as described here:

  • Test run folder. Directly under TestResults is one folder for each test run that has been started. The test run folder has the same name as the test run, as displayed in the Test Results window and the Test Runs window. The default format for test run name is <user name>@<computer name> <date> <time>. The test run folder also contains the cleanup scripts that are run before and after tests are run, as described in Steps in a Test Run.

  • Out folder and subfolders. Each test run folder contains a folder called Out. The Out folder is the actual deployment folder referred to in Steps in a Test Run. That is, assemblies and other files or folders that are required for the test run are copied to the <solution>\TestResults\<test run>\Out folder each time a test run is started.

  • In folder and subfolders. Each test run folder contains a folder called In. When certain test results are produced, they are stored in the In folder or a subfolder, as referred to in Steps in a Test Run. For example, code-coverage results are stored in a file called data.coverage in a subfolder named after the computer on which tests were run.

Choosing a Test Host

After copying deployment items, the Visual Studio test host runs the test in the deployment folder. In addition to the default Visual Studio test host, which is used for most kinds of tests, you can also select the ASP.NET host type for running ASP.NET unit tests. For more information, see Overview of ASP.NET Unit Tests.

Troubleshooting Test Deployment

The following problems can cause files not to be deployed:

  • File not found. If you specified the file using an absolute path, make sure the path exists. Also, did you check the file into source control using an absolute path?

    If you used a relative path, make sure that the root is at the location you expect. if the path contains an environment variable, make sure that the variable is set properly. If you are using a relative path that includes a configuration-specific directory such as Debug\bin\program.xls, are you currently using a different configuration so that the file does not exist in the expected location?

  • Access denied. Make sure you have access to the file that needs to be copied to the deployment folder.

  • File is on a network share. If the file cannot be copied because it is on a network share, copy the file to your local computer, indicate that the file in its new location must be deployed, and run the test again.

See Also

Tasks

How to: Configure Test Deployment
How to: Specify a Test Run Configuration
How to: Delete Test Results

Concepts

Testing Web Services
Instrumenting and Re-Signing Assemblies
Steps in a Test Run