How to: Specify Test Settings from Microsoft Visual Studio

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

You can specify settings for test runs. Test settings are saved to disk in files that have the .testsettings extension. You can create and save multiple test settings, and then make a specific test settings active. The active test settings is used when tests are run. For information about how to make test settings active, see How to: Apply Test Settings From Microsoft Visual Studio.

Note

There are two default test settings files. Local.testsettings collects only system information by default. If you want to also collect trace diagnostic data for use with the Visual Studio Historical Debugger and test impact analysis data to use to determine tests that are recommended to be run based on build changes, you must select the test settings file called TraceAndTestImpact.testsettings.

The procedures in this topic describe various aspects of working with test settings. The first group of procedures describes how to create and delete test settings.

The second group of procedures describes how to set the values within test settings. To set these values, you use the test settings editor, a dialog box that has the following pages:

  • General. On this page, specify a name for the test settings and an optional textual description. You can also specify a scheme for creating the names of test runs, which are used to identify test runs in the Test Results window.

  • Controller and Agent. Select whether to run tests on the local computer, or remotely using a test agent controller. Running tests locally lets you debug your tests and your production code. You cannot use integrated debugging when you run tests remotely.

    If you choose to run tests remotely, you identify the controller to use by specifying its network name or its IP address.

    Note

    When the test controller is the local computer, identify the computer by specifying localhost.

    You can also specify names and values for properties of an agent. If an agent being used has those properties, the test or tests you are running will use that agent. If no agent has the properties that were requested, the test run will fail.

  • Code Coverage. On the code coverage page, you specify what to instrument: which DLLs or .exe files, and, for ASP.NET projects, which directories. You can also specify whether to instrument in place and how to re-sign the files. This process starts by making a copy of the DLL. Then, the DLL is changed, that is, instrumented, so that code coverage statistics can be gathered from it during test runs. For more information, see How to: Obtain Code Coverage Data and Instrumenting and Re-Signing Assemblies.

  • Deployment. Before tests are run, Visual Studio can copy them to a deployment directory to ensure isolation and produce more reliable test results. Use the Deployment page to control deployment in two ways: You can disable or enable deployment by checking or clearing the Disable Deployment check box. Also, you can specify any additional files or directories that you want copied to the deployment directory. For more information, see Test Deployment Overview and How to: Configure Test Deployment.

    Note

    Do not select the Disable Deployment check box if you are working with smart device tests.

  • Hosts.

    • Select ASP.NET if you want unit tests to run in the same process as an ASP.NET site. If you select ASP.NET, you can make additional choices to configure the way ASP.NET tests are run. For more information, see Unit Tests for ASP.NET Web Services.

    • Select Smart Device if you want unit tests to run on a smart device or an emulator. Unit tests will be deployed to and run on the smart device or emulator that you specify. For more information, see Working with Smart Device Unit Tests.

      Note

      The Smart Device host only supports tests that are in smart device test projects. Tests that are in desktop test projects will not run correctly under the Smart Device host.

    • For other test types, including Web tests, choose Default.

  • Setup and Cleanup Scripts. On this page, you can select scripts to be run before tests are run, and after tests are run, respectively. To identify a script, type its path in the box under Setup Script or Cleanup Script. Alternatively, click the ellipsis (…). This opens the Open dialog box, which you can use to select a script file.

    Setup scripts and cleanup scripts run before and after test runs, regardless of the types of tests that are contained in those test runs. For more information about scripts that are run together with test runs, see Test Deployment Overview.

  • Test Timeouts. You can use this page to can specify time-out values for test run and for individual tests. For more information, see How to: Set Time Limits for Running Tests.

  • Web Test. Set values to be used when a Web test is run. Note that the Simulate Think Times setting is ignored when the Web test is aggregated into a load test. For more information, see How to: Set Think Times in a Web Test.

    Note

    You cannot configure all aspects of test runs by using the test settings editor. For some aspects, you need to directly edit the XML file that contains test settings. For more information, see How to: Edit a Test Settings File from Microsoft Visual Studio.

    Note

    The Controller and Agent page and the Web Test page are available only if you have Visual Studio Team System Test installed.

Creating and Removing Test Settings

This procedure is applicable only if your solution does not contain a test project, for example, for a solution that you have just created.

To add an initial test settings to your solution

  • Add a test project to your solution.

    A test settings is added automatically to the solution under the Solution Items folder.

    Note

    Each test settings that you create is listed as a choice for the Select Active Test Settings and Edit Test Settings options on the Test menu.

To add a subsequent test settings to your solution

  1. In Solution Explorer, right-click Solution Items and then point to Add, and then click New Item.

    The Add New Item dialog box appears.

  2. In the Categories pane, click Test Settings.

  3. (Optional) In the Name box, change the name of the test settings file.

  4. Click Add.

    The new test settings file appears in Solution Explorer, under the Solution Items folder.

    Note

    The list of test settings that Visual Studio displays — for example through the Select Active Test Settings option on the Test menu — is derived from the list of test settings files in the Solution Items folder. This means that if you move a test settings file to another location in your solution hierarchy, it can no longer be used as a test settings from within the Visual Studio IDE.

  5. The Configuration Settings - <test settings file name>.testsettings dialog box is displayed.

    You can now set and save test settings values.

    Note

    Each test settings you create is listed as a choice for the Select Active Test Settings and Edit Test Settings options on the Test menu.

To remove a test settings from your solution

  • Under the Solution Items folder in Solution Explorer, right-click the test settings that you want to remove, and then click Remove.

    The test settings file is removed from your solution. This change is reflected in the list of choices for the Select Active Test Settings and Edit Test Settings options on the Test menu.

Editing Test Settings Values

To edit a test settings if you have a solution open

  1. Under the Solution Items folder in Solution Explorer, double-click the test settings file that you want to open.

    - or -

  2. Point to Edit Test Settings on the Test menu and then click a test settings on the submenu.

    The Configuration Settings - <test settings file name>.testsettings dialog box is displayed.

  3. Make changes on the individual pages for each aspect of the test settings. For more information, see the descriptions of each page earlier in this topic.

  4. Click Apply, and then click Close.

See Also

Tasks

How to: Apply Test Settings From Microsoft Visual Studio

How to: Edit a Test Settings File from Microsoft Visual Studio

How to: Configure Test Deployment

How to: Obtain Code Coverage Data

How to: Set Think Times in a Web Test

Concepts

Test Deployment Overview