My colleague, Joe Ocampo, created a ReSharper template:

   1: [Test]


   2: public void


   3:    "$Specification$"()

To add the template, go to ReSharper->Options in the menu:

resharper_menu

Then choose “Live Templates” underneath the Templates heading from the items on the left of the popup window.  Under the “User Templates” section create a new template called “test” with the text above:

resharper_live_templates

When you write your unit test fixture with the “Given, When, Should” format, these items come in handy.  Once you get ready to write your test, you can just type the word “test”, then press tab and get the following in Visual Studio:

image

Ignore the red underlines and why the “TestName” word is on the next line.  The red lines will disappear after all of this is complete and the new line is necessary for the Visual Studio macro we’re about to create (so it can parse your test method name correctly).

You have to add a macro to Visual Studio via the Tools->Macros->Macros Explorer menu option (or use Alt+F8):

macros_menu

This will open the macros window.  Right-click “MyMacros” and choose “New Module”:

macros_window

Name the module TestMethodNameFormatterForBDD (or whatever you want to call it):

new_macro_window

This will add it back to the Macros window.  Double-click the new macro or right-click and choose “Edit”.  This will open the Microsoft Visual Studio Macros (MVSM) IDE.  Select all and replace the text with the following: