I’m a huge ReSharper fan. I consider it an essential tool. Without it you’re simply wasting your own time (or that of your employer, depending on how you see such things). Apart from extending Visual Studio with much better snippets, essential refactoring, static code analysis, intelligent code completion and much, much more, it allows you to spend so much more time without grabbing the mouse. Not just party-trick stuff; functionality that empowers you, tasks that could take hours, done in seconds.
Uhhh, I know all about ReSharper, just not how to run Unit Tests from the keyboard!
Of course never leaving the keyboard means using it for more than typing. This is typically either achieved through context menus (often displayed with the little used (and now I notice absent from my laptop) properties key), or, better, shortcut keys. Visual Studio is jam-packed with shortcuts, and the time spent learning them will pay off ten fold.
What ReSharper really gets, though, is context. Try refactor any piece of code through Ctrl-Shift-R, and the options appropriate to the member are filtered. Suggestions for code completion have insight into surroundings, suggest variable names I hadn't thought of yet, but actually wanted.
Light-bulbs appear, allowing the convenient Alt+Enter, a shortcut to actions that you might wish to perform.
A further bonus of ReSharper is the Unit Test Runner. Many argue that it’s not the best (it probably isn’t), but it suits my needs, and is included in an already required tool. One feature I really like (that I haven’t noticed elsewhere) is the console output, “remembered” by test. Using NHibernate, for one, I can easily examine the SQL being output, and peruse these statements conveniently long after the suite has run.
Yet despite the R# devs clearly having spent much time in the keyboard ninja dojo, it isn't immediately obvious how to simply run the tests you're working on from the keyboard. I put effort into keeping my tests focused and quick. I don’t want to have to stop coding and grab the mouse to see how my tests are going. ReSharper gets context, it really does. How did they forget this?
It's simpler than I realised. Embarrassingly obvious.
Visual Studio, of course, has the ability to bind shortcuts to actions (Tools - Options - Environment - Keyboard). Filtering these by “Resharper.UnitTest_” shows the applicable commands.
"ReSharper.UnitTest_ContextDebug", "ReSharper.UnitTest_ContextProfile", "ReSharper.UnitTest_ContextRun" debug, profile or run tests contextually. If the caret is within a test, only that test will be run, within a fixture (but not individual test) all tests in the fixture will be run.
ReSharper allows the selecting of tests to be run in sessions, arbitrary collections of tests you build up. "ReSharper.UnitTest_RunCurrentSession" will run all tests in the session currently selected (topmost in the window), and "ReSharper.UnitTest_RunSolution" will, well, run all the tests in the solution.
The hardest part is finding combinations of keys that aren't already assigned.
Technorati Tags:
ReSharper,
UnitTests
Thanks to Duncan for the heads up on this one.