Visual Studio 2012 Right Click "Create Unit Test" is gone?

Answered Visual Studio 2012 Right Click "Create Unit Test" is gone?

  • Monday, June 25, 2012 1:45 PM
     
     

    Hi...

    I´m testing VS2012 interface to check differences between it and 2010... very cool from now, but... there is something that I can´t find..

    Does the Right click over a method, "create unit Test" option is gone in 2012?

    That option was so much usefull, maybe is hidden somewhere?

    Thanks.

    Ing. Fucci Leonardo

All Replies

  • Monday, June 25, 2012 2:17 PM
     
     Answered
  • Sunday, August 19, 2012 1:54 PM
     
     
    VS2012 has been released and I still can't find the "create unit test" option when right-clicking over a method. Is this being worked on or was this feature removed?
  • Sunday, August 19, 2012 2:06 PM
     
     
  • Sunday, August 19, 2012 3:42 PM
     
     
    pvdg42 your response was not helpful. Nowhere in those links does it mention the "create unit test" stub feature.
  • Sunday, August 19, 2012 5:32 PM
     
     

    I'm sorry my previous links were not helpful.

    The unit testing has changed in VS 2012. Perhaps this walkthrough will be useful:

    http://msdn.microsoft.com/en-us/library/ms182532.aspx

    The right click shortcut you mentioned originally appears not to have made it into the RTM.

  • Monday, August 27, 2012 9:40 AM
     
     
    Wow that feature was a great productivity enhancer. So much so that I can't believe they released the product without it. I hope they add it back in future releases. I had seen several posts before RTM that it was on the bug list.
  • Friday, August 31, 2012 8:55 PM
     
     

    Hey MSFT how can a new product be released that regresses function?  Doesn't make sense that we can no longer generate test case stubs automatically.

    I just checked the links today and yes they have closed this issue as Working as Designed.  The comments indicate it as a backlog issue, but if that's the case why close the issue working as designed. 

    So the question now is : Has this feature been deep sixed?


    JP Cowboy Coders Unite!

  • Wednesday, September 12, 2012 11:31 AM
     
     
    workaround - use VS2010 to create Test proj and tests then open in VS2012
    • Proposed As Answer by Miguel Boléo Thursday, February 21, 2013 12:34 PM
    • Unproposed As Answer by Miguel Boléo Thursday, February 21, 2013 12:34 PM
    •  
  • Wednesday, September 26, 2012 2:31 PM
     
     

    pathul that's only a good work around for those of us who moved from 2010 to 2012, for any new developers who 2012 is their first version then that work around isn't going to help them.

    I have to agree though Microsoft has been blowing the unit test horn for years and stamping feet and pointing fingers at developers who don't... Then they take away the most efficient way to create unit tests (generate then tweak) :/


    The delete key, a programmer's sledge hammer.

  • Wednesday, October 17, 2012 11:36 AM
     
     
    This was a very important productivity feature! I really hope that it is added again asap!
  • Tuesday, October 23, 2012 4:21 AM
     
     

    You can create a legacy test project and classes use fine in VS2012.

    But, the more powerful mechanism is using t either xUnit or NUnit and the new Test Explorer.

    Only took a few minutes to install xunit via nuget and get a test case operational.


    Thanks, Robert

  • Thursday, November 15, 2012 1:39 PM
     
     
    Bummer. The right-click generate unit tests feature was awesome.  I'm sad now.

    Dirk Watkins

  • Monday, December 03, 2012 7:54 PM
     
     
    I agree it was a great productivity tool.  I am very disappointed that it is not in 2012, this should be fixed. 
  • Tuesday, December 04, 2012 8:47 PM
     
     

    The problem is not to create unit test, the problem is that the feature "Create unit test" over a method is gone... Even if the proyect was created previously.

    Also... 

    xUnit only works for Metro design, and also doesn´t provides this usefull option.


    I disagree about that Test explorer is a performant tool to developt test, it only works to see how many test do you have, and run it... that´s it. Test Tool Box on 2010 was powerfuller than Test Explorer. You must start coding the whole test from beginin..


  • Tuesday, January 29, 2013 2:07 PM
     
     Proposed Answer Has Code

    The menu item is still in place, but for unknown reasons it's invisible in the code editor. But you can use visual studio commands to run unit test wizard. The command you need is

    EditorContextMenus.CodeWindow.CreateUnitTests

    Open Command Window and type the command there.
    • Edited by digitali Tuesday, January 29, 2013 2:08 PM
    • Proposed As Answer by digitali Tuesday, January 29, 2013 2:08 PM
    •  
  • Tuesday, February 05, 2013 2:17 AM
     
     

    Please read this:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/03/08/what-s-new-in-visual-studio-11-beta-unit-testing.aspx

    Generate Unit Test Wizard – In VS2010 you could right click on a method in your code and we would generate a unit test into your test project. This wizard was very tightly coupled to MS-Test and depended on features like Private Accessors to do its work, so it was cut. We are exploring alternatives here, but don’t have any good solutions yet.

  • Monday, February 11, 2013 6:41 PM
     
     

    When I map this command in VS2012 it errors by saying:

    Command "EditorContextmenus.CodeWindow.CreateUnitTests" is not available.


    JP Cowboy Coders Unite!

  • Monday, February 11, 2013 8:43 PM
     
     Proposed Answer

    You can create a unit test shortcut in VS2012 by:

    1. Open Tools > Options > Environment > Keyboard
    2. Filter Create Unit Test command by typing “createunit” in the “Show Commands Using” text box
    3. Select It and choose “Text Editor” in “Use New Shortcut in” combo box
    4. Press the shortcut key you want

    • Proposed As Answer by gprayback Wednesday, April 03, 2013 1:14 AM
    •  
  • Tuesday, February 12, 2013 4:06 AM
     
     
    Thanks David, I must have been doing something wrong previously.

    JP Cowboy Coders Unite!

  • Tuesday, February 12, 2013 9:14 PM
     
     
    Did this work for you?  I tried it and I get the message that my shortcut "is bound to a command (Create Unit Tests...) which is not currently available."  Did I miss something?
  • Wednesday, February 20, 2013 2:03 AM
     
     
    I think the trick is to make sure both the Project to generate tests from and the Test Project are configured to run the same .NET Framework version.  In my case I think I got this same message when the project to create tests was using the .NET 4 client profile.  When I changed them both to 4.5 there were no problems.

    JP Cowboy Coders Unite!

  • Monday, April 08, 2013 4:07 PM
     
     

    Please read here:

    http://connect.microsoft.com/VisualStudio/feedback/details/736768/visual-studio-2011-beta-create-unit-test-menu-item-missing

    It appears it's a know issue, to be corrected.


    to be corrected... when? Update 2 just came out and this isn't back...

    http://about.me/bc3tech

  • Tuesday, April 16, 2013 4:19 PM
     
     

    I understand that it is being rewritten to support VS Testing, nUnit, and xUnit. Thankfully, it is coming back. No date on when it will be finished or released, however. Microsoft is working with VSTS Team Rangers to finish the job.


    Best wishes, Davin Mickelson


  • Monday, April 22, 2013 7:03 PM
     
     

    Okay so this circumvention given by Davod Hardin sometimes works and sometimes does not.  Today it doesn't work.

    I have added the command exactly as he's suggested and all I see is an error when pressing Ctrl+U, Ctrl+T for autogeneration.  The error says:

    "The key combination (Ctrl+U, Ctrl+T) is bound to the command (reate Unit Tests...) which is not currently avaiable".

    Losing 2 hours on this I thought ok try to download and reinstall most current Update which is Update 2.  Brought VS2012 up again, opened to the page with code in it, tried everything to generate Unit Tests, but kept getting this same message...

    What am I doing wrong?

    I have a regular WPF application, and a Test project in same solution.  Both are targetted to .NET 4.5.  I see the command in the context menu but it is grayed out.  Hitting the keyboard combination doesn't help.


    JP Cowboy Coders Unite!

  • Tuesday, April 23, 2013 4:28 PM
     
     

    For guaranteed results, if you could spend two more hours installing VS 2010, you could create your unit tests there. Then bring them back into VS 2012 once the scaffold tests were created. It's a crappy answer but it's also the simplest.

    Microsoft screwed this up in VS 2012 so we may need to slip back a version for some functionality until they get their "stuff" together. Cut bait or go fishing.

    Best wishes and good luck.


    Best wishes, Davin Mickelson

  • Tuesday, April 23, 2013 6:10 PM
     
     

    True Davin but I have a team of 25 developers all using VS2012 and I am responsible for training them how to write Unit Tests, which I can do by training them how to write the stubs manually, but I don't want to do that knowing what I know about autogeneration of Unit Tests!

    I just don't understand how this great feature could be so screwed up for so long since VS2012 came out, I just don't get it. 


    JP Cowboy Coders Unite!

  • Friday, May 03, 2013 3:51 PM
     
     

    Worked for me, awesome hack!

    FYI: I'm running VS 2012 Professional with Update 2, on a .NET 4 class library set of projects.

    Just followed the steps mentioned by David Hardin.

  • Friday, May 17, 2013 8:39 PM
     
     
    Tks, the solution works fine for me.