How to: Limit the Number of Stored Test Runs

Visual Studio saves information about every test run. This information is stored in files in a specific folder for that test run. You can typically find test run folders at this location: <your solution folder>\TestResults\<test run folders>

There are two ways to prevent these files from consuming large amounts of disk space:

  • You can turn off deployment of test items. When deployment is turned off, tests are run in place. That is, files that you need to run tests are not copied to a new folder before the tests are run. For more information about test deployment, see Test Deployment.

  • Visual Studio automatically limits the number of stored test runs by deleting old runs as you create new ones. You cannot turn off this feature. However, you can set the number of test runs that Visual Studio stores to any number between 1 and 9999, inclusive. The default number of test runs to store is 25.

Example

You might set the number of test runs to store to 25. The following sequence illustrates the events that could happen next:

  1. You start a test run.

  2. Visual Studio determines the number of test runs that are stored under the TestResults folder of the current solution. 

  • If the number is under twenty-five, Visual Studio runs your tests, creates a new test results folder for them, and writes the test results to that folder.

  • If the number is over twenty-four, Visual Studio displays a dialog box that asks whether you want the old runs to be deleted. If you click Cancel, nothing is deleted and your tests are not run. If you click OK, Visual Studio deletes old runs, starting with the oldest, until only four remain. When your current test run is saved, it becomes the twenty-fifth run, which puts you at the limit again for this solution.

    Note

    When Visual Studio enforces this limit, it deletes not only the test results files for a test run but also any files that were deployed for the test run. Any results that are deleted from the hard disk are also cleared from memory.

To limit the number of stored test runs

  1. In Visual Studio, click Options on the Tools menu.

    The Options dialog box appears.

  2. Expand Test Tools and click Test Execution.

  3. Under Test Results Management, select the number of test runs to keep.

  4. Click OK.

See Also

Concepts

Steps in a Test Run

Dialog Boxes of Test Edition

Other Resources

Test Deployment