How to: Run Unit Tests in MTA mode

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

You might want to run your tests in MTA mode (using multithreaded apartments) because of the methods that you have used to write your tests. For example, if you use a method such as WaitHandle.WaitAll that is not supported with STA (single threaded apartment), you must run your unit tests in MTA mode. By default unit tests are run using STA.

To modify your test settings file to run your unit tests in MTA mode, follow these steps:

Procedures

To run unit tests in MTA mode

  1. To open the solution that contains the unit tests that you want to run in MTA mode, click File, point to Open, and then click Project/Solution.

    The Open Project dialog box is displayed.

  2. Select your solution, and then click Open.

  3. To modify the test settings file, open Solution Items, right-click the test settings file, and point to Open With. Select a text or XML editor.

    The file is displayed in the editor.

  4. To set the unit tests to run in MTA mode, add the MTA mode attribute to the Execution element as shown in the following example:

    <Execution>
         <ExecutionThread apartmentState="MTA" />
    </Execution>
    
  5. Save the test settings file.

    Exit and restart Microsoft Visual Studio 11 Developer Preview.

    Reload your solution and run your tests.

    Your tests are displayed in the Test Results window when they run.

See Also

Tasks

How to: Run Unit Tests Faster Using a Computer with Multiple CPUs or Cores

Concepts

How to: Create and Run a Unit Test

Creating and Running Unit Tests for Existing Code