BT

Quick Unit Test Generation Returns to Visual Studio

by Jeff Martin on Sep 06, 2013 |

Back in Visual Studio 2010, developers had the built-in option to generate unit tests via a quick right click. This feature was removed in VS2012 and VS2013 Preview until now. The Visual Studio ALM Rangers have produced a new extension that restores a great deal of this functionality with the 1.0 release of Unit Test Generator.

The team is quick to note that this is not resurrection, it is replacement that is inspired by the previous tool. Among the project’s goals are:

  • Supports .NET MS-Test, NUnit and XUnit Test Frameworks and generation of VB/C# test code.
  • Presents a "reference implementation" of how to do this for a particular test framework.
  • It focuses on project and reference management and not on code generation.

By supporting 3 different test frameworks, (MS-Test, NUnit, and XUnit), developers are able to use the framework that works best for their project. The tool also allows for the customization of the project that gets created as well as the names for the namespace, class, method, and text of the method body.

Using the defaults would produce a default generated class that stubs out test methods set to fail with Assert.Fail(), so that they can be detected and replaced with valid tests.

Note that by design, the generator will only generate stubs for a public methods on a public class.  It will not generate any private methods or for a private class.  Combining this tool’s support for VS2012/VS2013 with project round tripping means teams should not have any difficulty incorporating the tool now and upgrading when ready.

Channel 9 has provided a brief walkthrough while a previous post by the ALM Rangers has a written tutorial based on release candidate.

 

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT