views:

114

answers:

3

Hi,

I have a 'suite' of VS2005 unit tests that attach a db as part of the initialization. Tests modify the db fairly substantially so need to revert it to a known state before each test run.

I deploy the test db to the 'out' folder of each TestResult and attach it in the MyClassInitialize method.

DB is fairly large so this uses up lots of space as more and more TestResults created.

Is there any way from within Visual Studio to limit the maximum number of testresults stored? ie. stores a max of 5 + deletes oldest when hits 5?

Regards,

Matt

A: 

One could create a method that runs on test initialization that browses to the proper location, and just uses file manipulation to delete a certain number, however the method you're suggesting might cause issues if multiple users attempt to run the unit tests at the same time (depending on how your test environment is setup).

The method I generally use is to create a copy of the database in test initialization, then on test tear down to delete the copy that's being used we generally append a guid to the database name to ensure uniqueness. The biggest issue with this method is if you abort the tests during debug the Database never gets deleted.

-MBirchmeier

MBirchmeier
A: 

As far as I can see, you cannot limit the number of test run results stored by Visual Studio.

Matt

Matt Randle
+1  A: 

This works from VS2010 (from MSDN):

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.

RaoulRubin
This really should be marked as the Best Answered
Scott Lance