Udostępnij za pośrednictwem


Test Deployment Overview

Visual Studio Team System Test Edition can run tests either in the folder in which you have created or generated them or in a separate deployment folder. You can choose whether to enable test deployment by making a test run configuration setting. For more information, see How to: Configure Test Deployment.

The separation that is enabled by test deployment helps make sure a cleaner test run and therefore, more accurate test results. In the deployment step, Test Edition copies deployment items, that is, files and folders, to the deployment folder before it runs tests. Test Edition 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 Test Edition.

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

    Note

    Your choice to enable or disable test deployment controls the deployment of all the items in this list: test files, dependent assemblies, and files that you specify explicitly. For more information about enabling and disabling test deployment, see How to: Configure Test Deployment.

For more information about all the steps that are 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 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 that you start a test run, Test Edition 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 named 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 named 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 every time that a test run is started.

  • In folder and subfolders. Each test run folder contains a folder named 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 that is named data.coverage in a subfolder named after the computer on which tests were run.

    Security noteSecurity Note:

    When you run a test under the smart device host, the files from the device's In folder are copied back to the desktop. To prevent execution of untrusted files, Visual Studio appends .txt to all files that do not end in either .txt or .log.

Choosing a Test Host

After copying deployment items, the test is run under the test host selected in the test run configuration. Most tests run under the default Visual Studio test host in the deployment folder. However, certain types of tests must run under a different test host, as described here:

  • ASP.NET host. Select this host when you run tests, such as ASP.NET unit tests, that must run under an IIS or ASP.NET development server process. For more information, see Unit Tests for ASP.NET Web Services.

  • Smart device host. Select this host when you run tests, such as smart device unit tests, that must run on a smart device or emulator. For more information, see Overview of Smart Device Unit Tests.

For information about how to select a test host, see How to: Specify a Test Run Configuration.

Troubleshooting Test Deployment

The following problems can cause files not to be deployed:

  • File not found. If you specified the file by using an absolute path, make sure that the path exists. Also, make sure that you checked the file into source control by 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 that you have access to the file that must 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 and indicate that the file, in its new location, must be deployed. Then, 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

Unit Tests for ASP.NET Web Services

Instrumenting and Re-Signing Assemblies

Steps in a Test Run