Bring back the "Create Unit Tests" feature from Visual Studio 2010?

2013-02-25

There's a feature request on User Voice that requests Microsoft to bring back the "Create Unit Test" menu item which was removed in Visual Studio 2012. I've seen it come up as a potential Ranger solution and it's been getting a lot of votes so far.

It turns out that the feature has been there all along, was it was just removed from the ever crowded right-click context menu? Or is there something else at work here? It's my belief, not confirmed or backed by the Product Team in any way, that it was removed to promote a better practice for writing unit tests. The fact that this feature only works for MsTest and not for the XUnit and NUnit, might also have been an influence to remove the menu item.

The danger of generating unit tests from the implementation is that chances are likely you'll be testing the implementation and not the actual functionality. This is a common problem with writing tests after writing the code. Since you already know exactly how the 'intended' functionality has been implemented, it's really easy to fall into the trap of mimicking or even duplicating the functionality in your test. The result is that whenever the implementation changes, your test is likely to fail, even when the functionality remained the same.

So, if you really liked the "Create Unit Test" menu item, sure, you can bring it back. But I'd strongly suggest you look at the way you write your tests.
 

Most Reading