How to: Configure Test Deployment
The test engine runs tests not in the folder in which you have created or generated them, but in a separate deployment folder. For more information, see.
The deployment folder can be local or remote. Remote test deployment occurs when you work with controllers and agents; for more information about remote deployment, see.
For local test deployment, test engine copies deployment items, both files and folders, to a folder on your computer before it runs tests. The following procedures describe how to select additional deployment items to be copied.
Select Deployment Items
The following procedures, in which you determine files or folders to be copied, differ in scope. The first procedure sets deployment items for a run configuration. These items will be copied whenever that run configuration is active. The second and third procedures apply to only one test method; they determine which files Team Edition for Testers copies before it runs that specific test.
To select files or folders to deploy, in run configuration
In Solution Explorer, under Solution Items, double-click the run configuration file that you want to edit.
A dialog box that has a name such as <run config file name>.testrunconfig appears.
Under Additional files or directories to deploy, specify additional files or folders to be copied. To do this, click Add file to select files; this opens the Add Deployment Files dialog box. You can also click Add Directory to select folders by using the Add Deployment Directory dialog box.
In the .testrunconfig dialog box, click Save and then click OK.
These deployment items will be copied to the deployment folder whenever this run configuration file is active.
To deploy items for a single test using the Deployment Items property
Select a test in the Test View window or in the Test Manager window.
The Properties window for that test is displayed.
Click the Deployment Items property.
An ellipsis (…) appears in the value column.
Click the ellipsis.
The String Collection Editor dialog box is displayed.
Before the test is run, type a path to a folder or a file that you want to have copied to the test deployment folder. Press Enter and type additional paths to specify additional folders and files to be deployed.
You can use environment variables in paths for deployment items. For an example, see.
The deployment items that you specified will be deployed in addition to those specified in the run configuration being used for the test.
For unit tests, code that specifies these deployment items is written into the source code for the test, in the DeploymentItem attribute.
To deploy items for a single test using the DeploymentItem attribute
Open the source-code file that contains a unit test. For more information, see.
Under the TestMethod attribute, add a DeploymentItem attribute.
For the parameter of the DeploymentItem attribute, specify the folder or file that you want to deploy for this test. You can use either an absolute path or a relative path. Relative paths are relative to the RelativePathRoot setting found in the .testrunconfig file.
Example in C#:
public void TestMethod1()
// TODO: Add test logic here
Example in Visual Basic:
Public Sub TestMethod1()
' TODO: Add test logic here
You can use the DeploymentItem attribute only on test methods, not on test classes.
Save and close the unit test source-code file.
When you run the test, the deployment items that you specified will be deployed in addition to those specified in the run configuration being used for the test.
Deployment items are copied in a specific order. Deployment items that are copied later overwrite those that were copied earlier, if they have the same name. For example, deployment items specified in run configuration are copied later than items specified for an individual test.
The following list is ordered from highest priority to lowest. That is, items listed first will overwrite items listed later. In the following list, certain items are deployed automatically to the deployment folder; these include the test assembly, instrumented binaries, and dependent assemblies.
The file or files that comprise the test. These include test assemblies, for unit tests; text or .mht files, for manual tests; or other types of files for other test types, such as generic tests.
Instrumented binaries. These are binary files that have been instrumented, for example, to enable code coverage.
If you are using in-place instrumentation, binaries are instrumented first and then copied to the deployment directory; otherwise, they are copied first and then instrumented. In-place instrumentation is the default setting for tests that are run locally; you can change this setting in run configuration.
Items specified in run configuration.
Dependencies, for example, application configuration files and dependent assemblies.
Per-test deployment items. These include items specified for the test method.