Visual Studio 2012 Shortcut Tips

Visual Studio 2012 Shortcut Tips

Would you like to Create Unit Tests in Visual Studio 2012? Here’s a quick guide that will tell you how to……..

Visual Studio 2012 has some great new productivity features to assist with testing and development but one of the most useful features from the previous version seems to be missing!

Visual Studio 2010 had a really handy function in the context menu called “Create Unit Tests”. This was accessed by right clicking on a class and selecting the option which then very quickly created basic unit tests for all the methods in the class. This was great for getting unit tests set up quickly.

Unfortunately, I and many others found this feature was missing from Visual Studio 2012. Well, fear not, the feature is still there, it’s just a bug in Visual Studio 2012 that has hidden it.

To resolve this issue simply go to Tools >> Customize and select the Commands tab. Then select the Context Menu radio button and select the Editor Context Menus | Code Window option in the drop down.

Visual Studio 2012

Then, in the Controls pane, scroll down until you see the “Create Unit Tests” item, click on it and then use either the Move Up button to move its position up one place. The click close and restart Visual Studio. After it’s restarted the option is back in your context menu as before.

While Unit Testing does require some extra effort on the part of the developer the benefits really do out-way the effort. Properly crafted unit tests help to reduce bugs and can increase developer productivity by focussing the developer on the task of passing the test. The end result is code that is robust and less prone to bugs and errors. This is a practice the development team at Bridgeall have fully adopted and embrace and use in all our development projects.