Are there shortcut keys for ReSharper's Unit Test Runner?
Asked Answered
C

12

71

For obvious productivity reasons, I make an effort of learning and using as many of the keyboard shortcuts for the various Re# commands.

However, it seems that the unit test runner does not have any associated shortcut keys. I want to be able to select certain tests and be able to run or debug them without resorting to grabbing the mouse each time. Is using the mouse my only option?

Callery answered 6/10, 2008 at 16:46 Comment(0)
Y
72

ReSharper adds items to Visual Studio's keyboard settings dialog box.

Go to:

Tools -> Options, Environment -> Keyboard

In the search bar, type "resharper" and see the vast options that you can control with the keyboard.

Specifically, there is one to launch the unit test explorer window, and there's a couple called

  • ReSharper.ReSharper_UnitTest_RunSolution
  • ReSharper.ReSharper_UnitTest_RunContext

that are likely what you need.

Yttriferous answered 6/10, 2008 at 16:58 Comment(6)
and in another note, I don't use this... I map CTRL+T to TestDriven.NET.Yttriferous
Ctrl+T now maps to 'Go to type' in R#, so I ended up using Alt+T as an alternative.Warbeck
Even - I thinks that's when you choose to preserve VS key bindings, which I don't. In fact, most R# users I know choose the R# key bindings, as they seem to feel more natural (at least to me)Yttriferous
unfortunately this activates the unit test session window, so when i want to continue coding, I have to switch back to the code window... :(Promissory
Handy shortcut. There ought to be a default for this.Tansey
As of R# 2023 these seem to be called ReSharper.ReSharper_UnitTestRunSolution and ReSharper.ReSharper_UnitTestRunFromContextEnharmonic
F
25

You could try ... ALT R U R
- if your cursor is in the Test method, then R# just runs that test
- if its in a test class, but not a method, R# runs all the tests in the class

Father answered 12/5, 2009 at 9:38 Comment(1)
Nice if you do last one D then you have debug!Premarital
M
18

As for running all tests in solution the command is Alt-RUN, i.e. ALT+R for ReSharper menu, U for Unit Testing, and N for all tests in solution.

And if you're using the R# shortcuts, the chord Ctrl-U, L will always do the job.

NOTE: I found this answer from from stackoverflow user ilya-ryzhenkov on a related question

Mezzanine answered 25/2, 2009 at 20:47 Comment(1)
that's fairly easy to memorize :)Twiggy
S
18

Resharper > 7 / Visual Studio 2012

You can find them in the defined shortcuts in Visual Studio 2012 under
[Tools] > [Options] > [Environment] > [Keyboard]

I usually use these:

+---------------------------------+----------------+
| Description                     | Shortcut       |
+---------------------------------+----------------+
| Run Test in Debug Mode (Editor) | Ctrl+U, Ctrl+D |
| Run Test (Editor)               | Ctrl+U, Ctrl+R |
| Run Tests from current session  | Ctrl+U, Ctrl+Y |
| Run Tests from solution         | Ctrl+U, Ctrl+L |
+---------------------------------+----------------+
  • Resharper.Resharper_Resharper_UnitTest_DebugContext
  • Resharper.Resharper_Resharper_UnitTest_RunContext
  • Resharper.Resharper_UnitTest_RunCurrentSession
  • Resharper.Resharper_UnitTest_RunSolution
Sapodilla answered 4/1, 2013 at 13:20 Comment(1)
This is an answer I can understand, almost no sentence, concisely presented in a tableDoerrer
W
7

For Resharper 4.5 OOTB:

Unit Test Explorer : Ctrl+Alt+U
Unit Test Sessions : Ctrl+Alt+T
Close Active Window : Shift+Esc

I just noticed last week that my keyboard has a right-click button between Alt and Ctrl on the right side, so no mouse needed to mouse to a specific test. Yeah!

Custom key mapping via Ben Scheirman's method:
ReSharper.ReSharper_UnitTest_ContextDebug : Alt+T, Alt+D
ReSharper.ReSharper_UnitTest_ContextProfile : Alt+T, Alt+P
ReSharper.ReSharper_UnitTest_ContextRun : Alt+T, Alt+T and Alt+T, Alt+R
ReSharper.ReSharper_UnitTest_RunSolution : Alt+T, Alt+S
ReSharper.ReSharper_UnitTest_RunSolution : Alt+T, Alt+A

Warbeck answered 15/5, 2009 at 21:32 Comment(0)
Z
4

I find the easiest way to recall these shortcuts is from the menu:

Resharper > Unit Tests

All the shortcut keys are presented next to each menu item.

Zoe answered 5/11, 2013 at 1:10 Comment(0)
L
2

You might want to check this short-cut cheatsheet.

BTW, even if there's no default key, you can probably bind one by going to the menu Tools->Options, and then to the sub-category General->Keyboard, and typing ReSharper in the search line.

Law answered 6/10, 2008 at 16:59 Comment(2)
OK, Ben Scheirman pointed out exactly what options you are looking for.Law
Here's the short-cut cheat sheet for Version 4.0: jetbrains.com/resharper/docs/ReSharper40DefaultKeymap.pdfFelipe
C
2

Since the time I originally asked this question, this is what I have been using:

Open 'Unit Test Explorer' and 'Unit Test Session' windows

Selecting a single test in 'Unit Test Session'

  • to select a test, use arrow keys to navigate

Selecting multiple tests in 'Unit Test Session'

  • to select multiple continous tests, hold the Shift key down while navigating with the arrow keys
  • to select multiple non-continous tests, hold Ctrl key while using arrows keys and toggle Spacebar to select/deselect tests

Run and execute tests in 'Unit Test Session'

  • press context menu button (found between the Alt and Ctrl buttons on most Windows-centric keyboards)

or

  • alternatively, press Shift + F10

  • navigate with arrow keys within context window and hit Enter on any selection

or

  • for Run Selected Tests, press R+Enter

  • for Debug Selected Tests, press D

Select call stack error line hyperlinks

  • if a test fails and the call stack is displayed splitting the 'Session' window, press Tab to navigate from the test section to the error links in the lower section

  • after tabbing to a specific error line, hit Enter to go to line of code with the runtime error

  • press Shift + Tab mutliple times as necessary to go backwards from the call stack (lower) section back to the unit tests (upper) section

Callery answered 11/3, 2010 at 7:58 Comment(0)
A
1

I know this is an old question but it's the top SO question on the Google results for the topic, so adding, just in case.

With Resharper V6, it starts with some keyboard mappings setup out of the box:

http://blogs.jetbrains.com/dotnet/2011/08/new-features-in-resharper-6-unit-test-runner/

Alvinaalvine answered 25/6, 2012 at 20:5 Comment(0)
D
1

RunCurrentSession command

You can collect your tests in a test session tab of Unit Test Sessions window. Then you can run all these tests by running command ReSharper.ReSharper_UnitTest_RunCurrentSession. ReSharper.ReSharper_UnitTest_RunCurrentSession command is assigned to Ctrl+R, Ctrl+U in my Visual Studio.

Disrelish answered 26/6, 2012 at 14:24 Comment(0)
F
0

Sadly, no, but I found this forum post

There are commands listed in the Tools - Options - Keybaord dialog of VS2008 for resharper unit test runner

Resharper.Resharper_UnitTest_ContextRun Resharper.Resharper_UnitTest_RunCurrentSession Resharper.Resharper_UnitTest_RunSolution

Have you tried assigning a keyboard shortcut to these, because I use MSTF and its own test runner, I run all my tests using its shortcut of ctrl r + a, and to run an individual test I either click on the resharper icon (I have Gallio installed) or use test driven.net context menu to run the test.

Forecourse answered 6/10, 2008 at 17:0 Comment(0)
C
0

It writes shortcuts in itself or website. Run Unit Tests: Ctrl+T, R
Debug Unit Tests: Ctrl+T, D
Run All Tests From Solution: Ctrl+T, Ctrl+L
Run Current Session: Ctrl+T, Y
Repeat Previous Run: Ctrl+T, T
Append Tests To Session: Ctrl+T, Ctrl+A
Create New Session: Ctrl+T, N
Unit Tests: Ctrl+Alt+T
Unit Tests Session: Ctrl+Alt+R
https://www.jetbrains.com/help/resharper/Reference__Keyboard_Shortcuts.html#unit_testing

enter image description here

Cabrilla answered 29/5, 2018 at 8:8 Comment(2)
You should also consider adding them in text format to your postConvolve
The picture is already clear and informative, we can look at the shortcut with our Visual Studio ourself.Alixaliza

© 2022 - 2024 — McMap. All rights reserved.