Share via


How to: Save and Open Test Results in Visual Studio

After you run a test in Microsoft Visual Studio 2010, the results of all the tests that were executed in that run are saved automatically on your computer in a test run file. You can open any test runs that were saved, view results of recently run tests, or save copies of test runs to a different location. How many test runs are saved automatically depends on a setting in the Options dialog box.

This topic is about using Microsoft Visual Studio 2010 to save and open test results. For more information about how to save and open test results in Microsoft Test Manager, see How to: View Test Results Using Microsoft Test Manager.

Note

Microsoft Test Manager is provided as part of Visual Studio 2010 Ultimate and Visual Studio Test Professional products.

Change how many test runs are automatically saved

How many test runs are saved by default dictates how many previously run tests you can open or copy to a different location.

To change how many test runs are automatically saved

  1. On the Tools menu, click Options.

  2. In the Options dialog box expand Test Tools, click Test Execution, and under Test Results Management set the number of tests that you want to have saved automatically.

Save test results to a chosen location

In addition to the tests that are saved automatically, you can save copies of test results to an alternate location for your convenience.

To save test results to a chosen location

  1. Open the test run that contains the test results you want to save.

    1. On the Test menu, point to Windows, and then click Test Runs.

    2. In the Test Runs window, in the Connect list, click the down arrow, and then click Connect to test run.

    3. In the Connect to Controller or Local Results dialog box, select either a remote controller or a local directory and then click OK.

      Note

      If you select a local directory, click Browse to find the correct TestResults folder. By default, results for locally run tests are saved to Visual Studio 2010\Projects\Project Name\TestResults.

  2. In the Test Runs window, double-click a test run to open the results.

    How many runs are available depends a setting in the Options dialog box that limits how many test runs are saved.

  3. In the Test Results window toolbar, do one of the following:

    • To copy all test results in the run, click Export Test Run Results.

    • To copy only selected test results, select the results you want, click the down arrow of the Export Test Run Results button, and then click Export Selected Test Results.

  4. In the Export Run or Export Selected Results dialog box, open the folder where you want to save the results and then click Save.

Open test results in Visual Studio

How you open test results depends on how they were saved. If you run multiple tests in a single session you can quickly open the previously run tests. You can also open tests that were saved automatically, or you can open tests that you saved to a chosen location.

To open results of recently run tests

  1. In the Test Results window, in the Select Run list, click the test run you want to open.

    How many runs are available depends on how many tests you ran during the current session. It may also be limited by a setting in the Options dialog box.

  2. (Optional) In the Result list, right-click a test and click View Test Results Details to see more information about that particular test.

  3. (Optional) For unit tests, in the Result list, double-click a test to go to that test method in your unit test code. If double-clicking does not open your test code, you may need to change a setting in Test Execution section of the Test Tools Tab of the Options dialog box.

  4. (Optional) To view test result details, including any data and diagnostic adapter attachments, click Run Details in the toolbar. For more information, see Setting Up Machines and Collecting Diagnostic Information Using Test Settings.

Opening and viewing test results and details

To open results of tests that were automatically saved

  1. Open the test run that contains the test results you want to view.

    1. On the Test menu, point to Windows, and then click Test Runs.

    2. In the Test Runs window, in the Connect list, click the down arrow, and then click Connect to test run.

    3. In the Connect to Controller or Local Results dialog box, select either a remote controller or a local directory and then click OK.

      Note

      If you select a local directory, click Browse to find the correct TestResults folder. By default, results for locally run tests are saved to Visual Studio 2010\Projects\Project Name\TestResults.

    The Test Runs window is displayed.

  2. Note   The number of test runs that are available in the Test Runs window depends on the setting in the Options dialog box that limits how many test runs are saved covered in the first procedure. In the Test Runs window, double-click a test run to open the results in the Test Results window.

  3. (Optional) To view test details, including any data and diagnostic adapter attachments, click Run Details in the toolbar. For more information, see Setting Up Machines and Collecting Diagnostic Information Using Test Settings.

  4. (Optional) For unit tests, in the Result list, double-click a test to go to that test method in your unit test code. If double-clicking does not open your test code, you may need to change a setting in Test Execution section of the Test Tools Tab of the Options dialog box.

To open test results that were saved to a chosen location

  1. On the Test menu, point to Windows, and then click Test Results.

  2. On the Test Results window toolbar, click Import Test Results.

  3. In the Import Results dialog box, locate the saved test results file and then click Open to view the results in the Test Results window.

  4. (Optional) To view test result details, including any data and diagnostic adapter attachments, click Run Details in the toolbar. For more information, see Setting Up Machines and Collecting Diagnostic Information Using Test Settings.

  5. (Optional) For unit tests, in the Result list, double-click a test to go to that test method in your unit test code. If double-clicking does not open your test code, you may need to change a setting in Test Execution section of the Test Tools Tab of the Options dialog box.

See Also

Tasks

How to: Analyze Test Runs Using Microsoft Test Manager

Concepts

How to: Delete Test Results

Running Tests

Other Resources

Running Automated Tests Using Microsoft Visual Studio