Los Techies : Blogs about software and anything tech!

TestDriven.NET keyboard shortcut


Continuing with the Palermo brain dump theme, Jeffrey introduced me to a keyboard shortcut for running TestDriven.NET tests from a keyboard shortcut.  I had been right-clicking and going from the context menu:

While the context menu is nice, it has me reaching for the mouse (like a chump).   Instead, I can set a keyboard shortcut to perform the same context-sensitive testing.

To set the keyboard shortcut, first go to "Tools->Options..." to bring up the Visual Studio Options dialog, then select the "Environment->Keyboard" screen:

In the "Show commands containing:" text box, enter "TestDriven" to get the the TestDriven.NET command quickly.  Select the "TestDriven.NET.RunTests" command and click the "Press shortcut keys:" text box.  Now enter the keyboard shortcut you like (I use 'Ctrl-T') and click the Assign button.  The shortcut key is not assigned until you click the "Assign" button.

Once you assign the shortcut, I additionally set the "Use new shortcut in:" to "Text Editor".  For some reason, setting "Global" wasn't enough, I had to set the "Text Editor" command also.

With this keyboard shortcut in place, you don't need to lift your hand to the mouse after writing your test.  The shortcut also works everywhere the TestDriven.NET menu works, so I can select a file, project, or solution in the Solution Explorer and run all of the tests with a quick keystroke.  Since the context menu gets pretty unruly, I save some time I normally spend searching through a menu that now stretches my entire screen.

Kick It on DotNetKicks.com
Posted Feb 27 2008, 08:42 PM by bogardj
Filed under:

Comments

Sean Chambers wrote re: TestDriven.NET keyboard shortcut
on 02-27-2008 9:28 PM

As an added benefit, if you are using ReSharper as well as TestDriven.NET installed you can do the same behavior in R# 3.1 or above. Follow the same instructions as here, in the commands containing type ContextRun. You can bind this to Ctrl-Shift-T. This will run only the test where to cursor is, or if the cursor is placed at the class level, it will run all tests for that class. It is currently not possible to bind a shortcut to run ALL tests in ReSharper however.

Chad Myers wrote re: TestDriven.NET keyboard shortcut
on 02-28-2008 12:05 AM

Wow... How did you get by without this before!!

TD.NET and R# work the same way with contexts:

- In or on a method, run that test

- In between or before/after methods in a class, run tests in that class

- In a class (.CS) file, but outside the class (namespace, etc) it still only runs that test class

- In Solution Explorer, selecting a file and CTRL+T on a file runs tests in that file, folder? that folder, project? that project solution? entire solution.

There's a shortcut to get the solution exp into focus, but I forget what it is.

Joey Beninghove wrote re: TestDriven.NET keyboard shortcut
on 02-28-2008 7:56 AM

> There's a shortcut to get the solution exp into focus, but I forget what it is.

Ctrl-Alt-L.  I use my Ctrl-Alt-L + Alt+H (hides tool window) combo all the time.  :)

Kevin Miller wrote re: TestDriven.NET keyboard shortcut
on 02-28-2008 8:34 AM

Jimmy, thanks for getting the good word out there. I could not breath without my TestDriven.Net shortcuts.

Alt+R --- Run test

Shift+Alt+R --- Rerun the last test   (this one is Really handy)

Alt+D --- Debug test

Shift+Alt+D --- Debug the last test

The ability to re-run your test makes the  Red-Green cycle go by much quicker. Write your test/code. Alt+R (Red). Write code to make your test pass. Shift+Alt+R (Green). No need to go find your test code to re-run the test.  

erichexter wrote re: TestDriven.NET keyboard shortcut
on 02-28-2008 4:35 PM

I am a big fan of driving R# using the standard shortcut /menu keys.

ie.

run all tests  Alt + R + U + N (RUN)

run current test Alt + R + U + <enter>

I have a very simple mind so the RUN command works well for me.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems