|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
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.
You might set the number of test runs to store to 25. The following sequence illustrates the events that could happen next:
You start a test run.
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.
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
In Visual Studio, click Options on the Tools menu.
The Options dialog box appears.
Expand Test Tools and click Test Execution.
Under Test Results Management, select the number of test runs to keep.