Is there a way to select which TestMethods you want to execute in Visual Studio 2008 Unit Test project while debugging? I want to debug one particular test without having my other TestMethods execute during each debug session.
There are probably other ways, but I install TestDriven.NET. It allows you to right click on a test method (MSTest, NUnit, MbUnit, etc) and select Run in Debugger. I highly recommend it.
Click on a test method name, then press Ctrl+R, Ctrl+T. (Or go to Test / Debug / Tests in Current Context.)
You've got two options when running tests. Look at your Test Tools toolbar. There are four buttons: Run tests in current context, debug tests in current context, run all tests, and debug all tests in solution.
When you want to debug a single test, you can put your cursor in the body of the test and click one of the "current context" test run buttons. To run all tests in a class, put the cursor at the test class name and click one of those buttons.
Alternatively, you can create a test list (Test->Create New Test List), and use that to select the tests you want to run. You can also use theis to disable and remove tests.
If you want to debug while running your tests under an ASP.NET solution, check out the MSDN article "How to: Debug while Running a Test in an ASP.NET Solution" at http://msdn.microsoft.com/en-us/library/ms243172.aspx.
I had to do this tonight and partially followed the instructions for "Debugging While Running on ASP.NET Development Server", setting in web.config and the System.Diagnostics.Debugger.Break() statement at the start of the method. However, I executed with the "Debug Checked Tests" command (Ctrl+R, Ctrl+T) which produced a Just-in-time debugger prompts and ran up a new instance of Visual Studio (I'm using VS2010 Beta2). It worked well.
CTRL-R + T = Run test in context. This can easily be triggered inside a test.
CTRL-R + A = Run all tests
CTRL-R + C = Run all tests in class
CTRL-R + N = Run all tests in namespace
CTRL-R + F = Run all checked tests (good for rerunning al failing tests)
CTRL-R + CTRL-T = Debug test in context, ie. it also attaches debugger
This also works for all other combinations.