When you’re doing unittesting in a project, there are two more shortcuts that would be nice to have.
These days, I’m running tests more often than I’m running the app, so why stop at having only the F5 so available for running the app in the debugger?
I have used ReSharper (R#) and TestDriven.NET, and none of them set up sensible shortcut keys to run or debug tests.
So here are the ones I use for running a test and another one for running a test in the debugger.
Setting up shortcuts in Visual Studio
I currently use TestDriven.NET for my unittesting, so I have set up the following shortcuts:
- CTRL+F5 to TestDriven.NET.RunTests
- CTRL+SHIFT+F5 to TestDriven.NET.Debugger
- ALT+F5 to TestDriven.NET.RerunTests will rerun the latest test again. (Regardless of current selection or the cursor position.)
- ALT+SHIFT+F5 to TestDriven.NET.ReRunWithDebugger
For R# the corresponding settings would be:
- CTRL+F5 to ReSharper.UnitTtest_ContextRun
- CTRL+SHIFT+F5 to ReSharper.UnitTest_ContextDebug
(No shortcuts for rerun with R#, since they don’t offer rerun in the same way…)
Depending on where the focus is and where the caret is positioned, they will both run the current method, all tests in a class, project or a solution.
I prefer TestDriven.NET for running the tests because its fast, and its ability to run any method with the testrunner (also methods not marked as tests).
Since R# is installed anyway, I still use R#’s testrunner sometimes because of the better test results visualization and filtering capabilities.