acidzombie24 acidzombie24 - 1 month ago 8
C# Question

Run specific unit test in Visual Studio

I am working on code and i have no console app to test with. I have dozens of unit test. I'd like to fix the code i am working on now but everytime i run it takes 30+seconds to do the unit test(I think reflection is the cause of some of these). This one and many others take < 1 sec to run but it is annoying to disable then enabled unit test.

Is there a way to say right now run this one test?

-edit- I'm using Visual Studio 2010 with the built in unit test system. Right click any code and select create unit test which creates a project.

Answer

Resharper and Test Driven .Net both have this feature in their visual studio test-runners. There may well be other VS plugins too.

According to this answer (By Jon Skeet no less) it is possible in Visual studio natively too. To debug a single test:

Click on a test method name, then press Ctrl+R, Ctrl+T. (Or go to Test / Debug / Tests in Current Context.)

EDIT: (based on a comment from Justin R below) to run a test (as opposed to debugging it) the command is simply:

Ctrl+R, T