Поделиться через


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 Test Deployment Overview.

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 Working with Controllers, Agents, and Rigs.

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

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

  2. Click Deployment.

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

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

  1. Select a test in the Test View window or in the Test Manager window.

  2. Press F4.

    The Properties window for that test is displayed.

  3. Click the Deployment Items property.

    An ellipsis (…) appears in the value column.

  4. Click the ellipsis.

    The String Collection Editor dialog box is displayed.

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

    Note

    You can use environment variables in paths for deployment items. For an example, see DeploymentItemAttribute.

  6. Click OK.

    The deployment items that you specified will be deployed in addition to those specified in the run configuration being used for the test.

    Note

    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

  1. Open the source-code file that contains a unit test. For more information, see How to: Author a Unit Test.

  2. Under the TestMethod attribute, add a DeploymentItem attribute.

  3. 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#:

    [TestMethod]

    [DeploymentItem("MyTestProject\\testdatasource.mdb")]

    public void TestMethod1()

    {

    // TODO: Add test logic here

    }

    Example in Visual Basic:

    <TestMethod()> _

    <DeploymentItem("MyTestProject\\testdatasource.mdb")> _

    Public Sub TestMethod1()

    ' TODO: Add test logic here

    End Sub

    Note

    You can use the DeploymentItem attribute only on test methods, not on test classes.

  4. 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 Order

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.

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

  2. Instrumented binaries. These are binary files that have been instrumented, for example, to enable code coverage.

    Note

    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.

  3. Items specified in run configuration.

  4. Dependencies, for example, application configuration files and dependent assemblies.

  5. Per-test deployment items. These include items specified for the test method.

See Also

Tasks

How to: Configure Test Project Creation
How to: Configure the Dialog Boxes of Team Edition for Testers

Reference

DeploymentItemAttribute

Concepts

Test Deployment Overview
Working with Controllers, Agents, and Rigs
Instrumenting and Re-Signing Assemblies

Other Resources

Configuring Test Execution