Quick Unit Test Generation Returns to Visual Studio
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.
Brandon Holt, Preston Briggs, Luis Ceze, Mark Oskin May 21, 2015
Kai Kreuzer, Olaf Weinmann May 21, 2015