Where is the "Create Unit Tests" selection?
The "Unit Test Generator" extension is available
To add directly from Visual Studio 2012/2013 IDE:
- Menu: Tools -> Extensions and Updates
- Click: Online -> Visual Studio Gallery
- Search for: "Unit Test Generator"
MSDN Video Demonstration
Note: MSTest in VS 2012/2013 still sucks
Here is how to to enable it again :
Method 1 - Command Window
If you find hard enough, you will discover that the command to invoke the Create Unit Tests... is actually:
EditorContextMenus.CodeWindow.CreateUnitTests
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.
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.
You will realized that the menu item is actually available in the context menu. The VS developers were kind enough to leave it there for us.
Click on the Create Unit Tests... menu item and click Move Down until it's on/under the "Run tests.." Command. Then click Close.
Restart Visual Studio 2012 and that's it ! The context menu will be available!
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.
Source(with images, i don't have enough Rep Points to put them) :
http://serena-yeoh.blogspot.fr/2013/02/visual-studio-2012-create-unit-test.html
(ps : read the Caveats !!!! )
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. Or type an alias command as follows
alias ut EditorContextMenus.CodeWindow.CreateUnitTests
and assign the alias to run command faster.
Another way to run the wizard is keyboard shortcut. In Visual Studio open
Tools -> Options -> Environment -> Keyboard
Type "createunit" in "Show commands containing" text box to filter out CreateUnitTests command, select it. Choose "Text Editor" in "Use new shortcut in" combo, and press shortcut you want in "Press shortcut keys" text field (e.g., Ctrl+T, Ctrl+C). Finally, press Assign button. Enjoy!
This feature was cut from VS.
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.
EDIT There is a work around: http://blogs.msdn.com/b/malaysia/archive/2013/02/20/right-click-create-unit-tests.aspx