Can I add a command to make ReSharper repeat last test run to the right click context menu in visual studio?

automation, contextmenu, resharper, right-click, visual-studio

Solution

I really enjoy TestDriven's re-run. It's great for spelunking into a problem, setting breakpoints, running tests, making changes, re-running, etc. If the last time you ran the test you had it "Test with > Coverage" or "Test with > Debugger", then that's the setting it uses for repeat.

The closest Resharper comes to that is `Resharper_UnitTest_RunCurrentSession` which will run whichever tab is selected in the "Unit Test Sessions" window. It won't repeat the last test run's mode (run or debug), or run only the tests from the session that were run the previous time.

You can bind a keyboard shortcut to `Resharper_UnitTest_RunCurrentSession` via Tools > Options... > Environment (section) > Keyboard (section). The full command name is `Resharper.Resharper_UnitTest_RunCurrentSession`.

Adding it to the context menu is different for Studio 2008 and Studio 2010, but both get started from Tools > Customize.

Update for R# 6: There is now a `ReSharper.ReSharper_UnitTestSession_RepeatPreviousRun` command that does exactly what we hope it does.

Problem

I'd like to add a context menu item to allow me to repeat resharper's last test run, similar to the one that test driven.net adds. Is this possible?

Original source