Right-Click, Create Unit Tests

For those who are disappointed with the removal of the "Create Unit Tests..." context menu in Visual Studio 2012, here are few methods for you to re-enable the feature:

Method 1 - Command Window
If you find hard enough, you will discover that the command to invoke the Create Unit Tests... is actually:
You can actually type that in the Command Window to invoke the Create Unit Test Wizard. If you find it too verbose, you can actually create an alias for it.
alias ut EditorContextMenus.CodeWindow.CreateUnitTests
Then just type ut to launch the wizard.

Method 2 - Keyboard Shortcut
The next method is to go to Tools->Options->Environment->Keyboard and set a shortcut key of your preference.

Method 3 - Re-enable the Create Unit Tests... Context Menu.
This is by far the best method ever. To re-enable the Create Unit Tests... menu, go to Tools->Customize... to launch the Customize dialog. At the Customize dialog, go to the Commands tab, select the Context menu radio button and choose Editor Context Menus | Code Window.

Thanks to our MVP Serena Yeoh for sharing such a great information with us, you can click here to see the full details.

Comments (12)
  1. Definitely voting to bring back this feature to VS2012.

    Voting is being considered already:


  2. michael freidgeim says:

    Your re-post missed the most important part of the original blog:


    You may discover that using any of the above methods may not work. i.e. The Command Window will tell you that the command is not available, the keyboard shortcut will not fire or the Context menu will be available but disabled.

    To allow all these to work, you will first need to have a Unit Test Project in your solution. After creating the Unit Test Project, you will need to manually Add a Unit Test item to the project even though the project unfolds with one on its own. After you have done this, everything will function as it is like back in Visual Studio 2010. You can safely remove those UnitTest1.cs files.

  3. Excellent says:

    Thanks full post and michael freidgei's work around to enable create unit test helped me a lot.

  4. Wes says:

    There seems to be a step missing in "Method 3"

    I see the "Create Unit Test" option in the customize window as shown in the screenshot… but do I need to do something to it to enable it?

  5. Gaurav says:

    Hi Wes,

    were you able to enable "Create Unit Test"? I still can not figure out how to enable it.

  6. Christopher says:

    If you use the link at the bottom of the post it has more information. You have to move the unit test up and then down, close, and restart the program.


  7. Robert B. Christensen says:

    I got it to work. But… How can I test non static methods? The wizard only sees static methods.

  8. HL says:

    This is great in VS2012 – but it does not work in VS2013 – Microsoft seem determined to remove this feature.

  9. GerryF says:

    I have tried the options suggested and none of them work for a console application in

    visual studio 2013 ultimate if you create an MVC project it will auto generate the utest unit

    class for you but not in a console app it comes back with

    Command "EditorContextMenus.CodeWindow.CreateUnitTests" is not valid.

    when you try the command window

  10. RitchieD says:

    VS 2013 ultimate (v 12.0.30110.00 update 1)

    CreateUnitTest does not exists in any of the three choices.

    I did create a test project and manual test script, that works.

    But these Generate does NOT exists in my version of VS.

  11. SId says:

    Non of the method works for 2013 ..

  12. Srinivas says:

    Michael freidgeim, Thanks a lot. It worked for me using VS 2012

Comments are closed.

Skip to main content