HOWTO: Change which “.testsettings” file Visual Stuido 2010 uses

I’m blogging this mainly for historical reasons.  I just spent over 30 minutes trying to figure this out.  Well, the first 10 or 15 minutes was getting code coverage enabled in Visual Studio 2010.  There’s plenty of coverage on that topic since it’s not as intuitive as it could be.  I’ll let Google handle that one.

Visual Studio 2010 allows you to create multiple “testsettings” files in your solution.  This allows you to set up customized configurations to control deployment, code coverage and a ton of other settings.  My solution has two settings (I think these are the defaults): “Local.testsettings” and “TraceAndTestImpact.testsettings”.  I configured Code Coverage in my “local” test settings.  I then ran my unit tests and went to check out the code coverage.

Visual Studio told me there was no code coverage data available – and prodded me to check the test results for errors.  I looked at the test results and didn’t see any errors but I did notice one thing.  The “Results Summary” for my test run displayed:

Test settings: TraceAndTestImpact

Ah ha!  So it’s not using my Local settings.  All I need to do is tell the unit tests to run with the “local”  testsettings file and I’ll be all set.  But how do I do that?  A few Google searches didn’t reveal much.  I finally (out of desperation), checked the ol’ drop down menus.  Under “Test” there is an option called “Select Active Test Settings”.  Under there, you can pick which settings file to use.



1 Comment

  • One other thing - sometimes changing this does not actually take effect; and you have to restart visual studio for it to work.

    I've seen this issue with the "deployment" feature of the test framework.

Comments have been disabled for this content.