Unit Test Generator

Free

Generates unit test code for methods in classes under test.

(36) Review
Visual Studio
2013, 2012
Download (55,758)
5/20/2014
1.3.14.510
View
E-mail Twitter del.icio.us Digg Facebook
Add to favorites
Description
Reviews (36)
Q and A (33)
Sign in to write a review
Sort by:

by RingDotNet | July 15 2014

AWESOME !!!

Finally something to replace the functionality that was removed from VS.
It does exactly what I need it to do. I installed it through VS's "Extensions and Updates" wizard and had no problems.
IMHO it works better than what was taken out of VS.

Thanks Guys for providing this functionality through an extension. I'll use it a lot.

by immeraufdemhund | May 21 2014

This simple tool makes adding unit tests for my classes a breeze. Especially when I am implementing a interface. Just create my class, implement the interface classes. Right click and generate all my tests.. then start knocking out my methods one by one good old TDD style. I love it. Great tool. I would how ever like to see something like Netbeans and IntelliJ to when generating tests in that they make a instance, a actual, and a expected variable for me. Granted it's not always right, but it's nice to have the majority of that put in. Just a thought.

by BlogTroll | May 07 2014

Does exactly what it promises, setting up the plumbing and creating one test method, or a test method for EVERY public methods of a public class. Obviously not the same as the discontinued feature, but then it states that clearly. It obviously assumes that you have reviewed the blog posts and documentation listed with the extension.

by Ojemzy | April 30 2014

Erm doesnt work at least on Express 2013.. 1 hr of trying.

Cant even upload image of pop-up error.


30/04/2014 20:27:24 - Searching for applicable products...
30/04/2014 20:27:24 - Found installed product - Microsoft Visual Studio 2010 Premium
30/04/2014 20:27:24 - Found installed product - Microsoft Visual Studio Express 2013 for Web
30/04/2014 20:27:24 - Found installed product - Global Location
30/04/2014 20:27:24 - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
at VSIXInstaller.App.InitializeInstall()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Visual Studio ALM Rangers May 20 2014
| Edit |
Delete

As outlined in the release notes and documentation you require Professional or higher. Express is not supported.

by Bala Subra | April 24 2014

Must have in every dev env

by GBotros | April 16 2014

by Micky D | April 15 2014

Works exactly as described. Compatible with Resharper

by smarty420 | April 03 2014

People who ever developed this plugin ,please don't call yourself a programmer. This is a useless tool that does nothing . Its a shame on MS , that they can't get a back cool feature that is needed by its developer community , even after two releases of visual studio.

by Bgardner21 | March 20 2014

It would be really nice if it picked up on the InternalsVisibleTo setting, and allow you to create unit tests for internal classes in the project. Aside from that, it works well.

by bsolomon | March 20 2014

Better than nothing. All the positive ratings here must be from those
who do not know or remember the vs2010 version.

The original version would create test cases with a template call to
the method under test, AND would also allow you to create test cases
(with calling stubs) for EVERY method in a class, not just one at a time.

by AAAZ | March 09 2014

Terrible....

Who's idea was to remove from VS 2013 "Create Unit Test"?

This solves nothing. It does not create the auto code generated that
we enjoyed on VS 2010,12

VS 2013 Testing features has gone back in time 10 years.

by Atrejoe | March 05 2014

Thanks for restoring this functionality to Visual Studio!
Nice to haves:
- Register keyboard shortcut upon instllation, like ctrl-U(nit)-T(est)
- Add Xml comments to generated code.

by Grynchuk Anatolii | February 24 2014

bull shit :(. No comments... Just do nothing.

by TheBigFont | February 13 2014

Easy to use out of the box.

by D. Oliana | February 11 2014

by cml1 | February 01 2014

Error "Controller must have testable element property set up" when try to generate test for method in struct.
(Ugly workaround: change "struct" to "class", generate test, change to "struct" ;)

by ImadMN | January 28 2014

It has a bug when creating a test class in a C# project from a VB class.
Can you solve it, please ?

by Anatolii Grynchuk | January 09 2014

Unnecessary tool whith generating body like Assert.Faile or empty. Actually this tool does nothing for now. Whould be better to generate a method like

//arrange
$END$

//act

//assert
Assert.Fail("Not implemented");

by CAD bloke | November 13 2013

Four and nine-tenths stars.

Count me in on the chorus for wanting Internal classes and methods when InternalsVisibleTo is set. I rate this as more important than a batch test generation. I'm happy to generate tests as I need to.

For those using ReSharper, I use this naming setup so it looks sensible in the test runner:

Project name: [Project]Tests
Namespace: [Namespace].Tests
Class Name: [Class]_Tests
Method Name: [Method]Tests_go_here

by IanRelease | October 29 2013

Excellent. One thing I would like is ability to specify naming rules for the project or even choose an existing project.

1 - 20 of 36 Items   
Sign in to start a discussion


  • Doesn't work with interface implementations?
    3 Posts | Last post Thu 5:40 PM
    • I'm not seeing any menu item to generate tests when clicking on methods explicitly generated from an interface.  Is this because they are not "public"?  My goal was to create mocks around interfaces and then test them in isolation. 
      
      Am I missing something?
    • Just installed... same issue. 2013 Premium as well. I have used this successfully with past versions. Sure hope someone replies with a way to check this install.
      
      I don't see anything to configure and no Generate Unit Test option anywhere.
      
      I am using Public methods and still don't see anything. Tried reinstalling, still nothing.
      
      Help guys... please.
      
    • I got it working... oddly. The class I was trying to generate from was Public WCF as was the Method. However it inherited from an Interface. Have no idea why this would not work.
      
      I dropped out of that project, created a dummy test class and method. This enabled the Generate Unit Test options. Then I was able to go right back to the original class and it works.
      
      I guess it just needed to be initialized in a simple class first. Maybe this isn't a fix, but its working.
      
  • installed - in tools, but no generate unit test
    4 Posts | Last post Tue 5:28 PM
    • I have VS2013 ultimate, tools/extension show I have 1.2.13.1101 installed, and under Test I have Configure Unit Test Generator, but no Generate Unit Test shows when I right click on class or methods. Ideas ?  I have VS 2012 installed with same issue. Is there any other way to invoke it ?? What next ?
    • After I built the project then the Generate showed up... not sure if a build is prerequisite to getting the generate enabled...
    • Is your class and the method of focus public?
    • I have a similar problem, and my class is internal. When I change the class to public, the "Generate Unit Test" menu option appears.
      
      Unfortunately, almost all of our classes are internal and I've always just added an InternalsVisibleTo attribute in the AssemblyInfo.
      
      Is there anyway to get this extension to work on internal classes?
  • Corrupt Visual Studio 2013 Update 2
    1 Posts | Last post June 16, 2014
    • After I installed "Unit test Generator" on my Visual Studio Premium 2013 Update 2, it corrupted all my projects...
      1) First thing that happen is none of my projects can be loaded. For all "csproj", it says "Application is not installed".
      Un-install / re-install the extension does not solve issue.
      I eventually solved the problem by running devenv /ResetSkipPkgs
      I can also recreate this problem by installing the "Unit Test Generator" again.
      2) Second problem I cannot resolve myself, when I try to create a view in MVC project, I got the error:
      There was an error running the selected Code Generator:
      "No Exports were found that match the constraint:
      ContractName
      NuGet.VisualStudio.IVsPackageInstallerServices
      RequiredTypeIdentity
      NuGet.VisualStudio.IVsPackageInstallerServices
      
      I can still create Controllers, class etc... when I tried created a view, it's the problem...
      
      Anyone know how to fix this error? I tried devenv /ResetSettings or /resetuserdata, none of that works...
      
      Any idea? Thanks.
      
      
      
      
      
  • please help with how it mangles project references
    7 Posts | Last post May 28, 2014
    • Hi Folks
      
      My background is mostly JUnit and NUnit (but my current employer wants folks to start using MS Test).
      
      I've been going a little nuts today with the Microsoft Testing Framework, let me explain:
      
      1. Had (MS) unit testing already running just fine (but all was included in the same project MyProject)
      
      2. I wanted to split this out into it's own MyProjectTests for MyProject (which I thought would be all of a 5 minute process, and keep projects in the same solution)
      
      3. Upon right-clicking and generating test stubs for classes in MyProject and into MyProjectTest, Visual Studio 2013 took a FULL crash with a disk space err (which makes little or no sense, since I had 519 GB available)
      
      4. It took me about an hour to fix manifest issues and bizarre stuff (like "ambiguous reference(s) to abc extension" where there was only 1 copy in the project <- renaming these fixed those issues in the proj manifest)
      
      OK, so now I have:
      
      namespace InternalTools.MyProject (for MyProject) which I'm trying to call classes from namespace InternalTools.MyProject.Tests (MyProjectTests project)
      
      for the life of me and can not understand why in the MyProjectTests, under a [TestMethod()] (which is what the extension creates), I can't reference InternalTools.MyProject.MyClass (VS see's the InternalTools.MyProject. as validate, and the MyClass is public (in the main project), but IntelliStupids doesn't know what to do with it and it does show in the Error List?)
      
      anyone experience this before? (this is actually taking more time than the writing of the code) and again, all of my original unit tests WERE running when everything was in MyProject.
      
      please give me a hand here folks. all of the forums I've posted this question on recommended that I walk away from MSTest (and stick with NUnit which I know and like) due to memory leaks, stuff like what I've subscribed, etc.
      
      disappointment, since we are a Microsoft Partner and should be able to transfer this knowledge 
    • some more details:
      
      1. this is a console application (it's main purpose is to function like a CSVLint)
      
      here's an outline (of the MyProject and MyProjectTests):
      
      (MyProject)
      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Globalization;
      using System.Linq;
      using Microsoft.VisualBasic;
      using Microsoft.VisualBasic.FileIO;
      using Microsoft.VisualStudio.TestTools.UnitTesting;
      using System.IO;
      using System.Reflection;
      using System.Text;
      namespace InternalTools.CSVValidate
      {
      class CSVValidate...
      }
      public static class ArrayUtils...
      public class Utils...
      public class CmdArgExtractor...
      namespace InternalTools.CSVValidate.CsvParser
      {
      public class CsvParser...
      }
      public class CsvSerializer<T> where T : class, new()
      public class CsvIgnoreAttribute : Attribute { }
      public class InvalidCsvFormatException : Exception
      
      (MyProjectTests)
      
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Collections;
      using System.ComponentModel;
      using System.Globalization;
      using System.IO;
      using System.Reflection;
      using Microsoft.VisualStudio.TestTools.UnitTesting;
      using Microsoft.VisualBasic;
      using Microsoft.VisualBasic.FileIO;
      using InternalTools.CSVValidate;
      
      namespace InternalTools.CSVValidate.Tests
      {
          [TestClass()]
          public class CsvParserTests
          {
              [TestMethod()]
              public void ParseTest()
              {
                  Assert.Fail();
              }
      
              [TestMethod()]
              private string[][] Parse(string input)
              {
                  InternalTools.CSVValidate.CsvParser.CsvParser parser = new InternalTools.CSVValidate.CsvParser.CsvParser();  <-- CAN NOT figure out the class/namespace even though IntelliStupids is OK
      
                  using (StringReader reader = new StringReader(input))
                  {
                      return parser.Parse(reader);
                  }
              }
          }
      }
    • Respectfully, I'm going to give this another hour or two to try to figure out.
      
      After that, and respectfully, you folks I'm sure have put in a lot of effort and time, time, but MS needs to get involved here at the top management and product levels. I hold product management accountable for "another" mess. (Already got burned several years ago when they pulled the Windows Service Project templates out of VS and had to resort to MS Engineers Googling to figure out how to make things run as a .NET Service. Again, simple 101 Product Mismanagement...
      
      Finally, I'm running VS Studio 2013 Ultimate if this is of any usefulness.
      
      Rob K
    • OK, figured out the root problem and this is a BUG FOR THE RANGERS.
      
      The Main Project --> MyProject is running on framework v4.5.1
      
      When you run this extension for the first time, it HAS NO CLUE as to what the framework of MyProject is (and/or it simply ignores it). A double-check of MyProjectTests revealed that it created the project (both under the same solution as framework v4.5 and not v4.5.1).
      
      A change of MyProjectTests from v4.5 to v4.5.1 fixes everything.
      
      Rob K
      PS If you rangers need any more details I'm at tutor@ebiz-developer.com
    • noticed RichLawley's post on the framework mismatch from Sunday.
      
      wish I'd noticed it sooner, it would have saved me a half a day :)
    • here's another one.
      
      when you create a MyProjectTests project, it seems to "crash" compile-ability with extension methods.
      
      so stuff like (in MyProject):
      
      	public static class ArrayUtils
      	{
      		public static string[] ToStringArray<T>(this IEnumerable<T> items)
      		{
      			return items.Select(i => i.ToString()).ToArray();
      		}
      		public static T[] RemoveAt<T>(this T[] source, int index)
      		{
      			T[] dest = new T[source.Length - 1];
      			if (index > 0)
      				Array.Copy(source, 0, dest, 0, index);
      
      			if (index < source.Length - 1)
      				Array.Copy(source, index + 1, dest, index, source.Length - index - 1);
      
      			return dest;
      		}
      	}
      
      starts throwing errors like:
      
      The call is ambiguous between the following methods or properties: 'InternalTools.MyProject.ArrayUtils.RemoveAt<string>(string[], int)' and 'InternalTools.MyProject.ArrayUtils.RemoveAt<string>(string[], int)'
      
      Rob K
      PS regretfully, I really think Product Management for VS needs to step up to the plate hereand think this one out better.
      
    • Bug #2
      
      Something in the Unit Test Generator extension mangles "extension methods" in the MyProject scope. This happens because the process of creating MyProjectTests mangles the references in MyProject by "self referencing". 
      
      (Yup, this is the Generator, because prior to it's introduction, MyProject worked for weeks w/o any sort of "funny business".)
      
      Even more fascinating is that VS 2013 Ultimate would even let this happen? (Can't think of a single scenario why a project would self reference or this would be legit in VS? <- maybe a bug for the VS team too.)
      
      Rob K  
  • Customisation of new project template
    1 Posts | Last post May 25, 2014
    • Is it possible to customise the template used to create a new test project?  For example, every unit test project I write includes Moq and custom assertion libraries, and it would be helpful if these didn't need adding every time.
  • Target Framework not set
    1 Posts | Last post May 25, 2014
    • If you try to generate a unit test for a project targeting 4.5.1 where no unit test project currently exists, the generated test project targets 4.5 and is therefore unable to reference the code being tested.  I have to change the target framework manually.  It would be good if the target framework were copied from the source project.
  • Controller must have testable element property set up
    1 Posts | Last post April 17, 2014
    • VS 2013 doesn't work. When I choose my method and right-click -> Generate Unit Test I get an error: "Controller must have testable element property set up". 
  • Cannot generate unit test in Module
    6 Posts | Last post March 02, 2014
    • As a new developer generating unit tests is outstanding!  
      
      But, it only works in Classes, not Modules.  Most of the non-form code in my app is in a set of modules, so this is sorely missed in VS 2013.
      
      I'm on W7 Pro, VS 2013 Pro, with VS 2010 Pro also installed.
      
      This was previously documented as bug 8675, but has returned?
    • @Dan, I just tested the v1.2 extension and it works in both classes and modules. Can you share some sample code which fails on your side, so that we can investigate?
      
      Bug 8675 was fixed in v1.1.
    • I should have been more specific.  The issue is that Generate Unit Test does not appear in the context menu when I right-click on a method in a Module, while it does appear when I right-click on a method in a Class.  This is also occurring in V1.2.
      
      Generating a unit test in a Class works fine.
      
      Thanks!
      Dan
    • @Dan, I just re-tested v1.2 and the feature lights up in the context menu in a public method within a module. Can you possibly record a repro so that we can investigate?
    • Hi Willy,
      
      I just reinstalled VS 2013 with Update 1, uninstalled and reinstalled UTG, but I still have the same problem.  If no one else has this issue, I would probably need to reformat my C drive to get it resolved.
      
      Thanks!
      Dan
    • Hi Willy,
      
      To solve a different problem, I went through my registry and removed every item I could find which referred to 'Visual Studio 10'.  Then I did a repair on VS 2013.  That fixed my other problem and also now shows Generate Unit Test in the context menu when I right-click a procedure in a module.
      
      All is good now.
      
      Thanks!
      Dan
  • Generate unit tests context menu doesn't contain list of my existing test projects
    1 Posts | Last post February 12, 2014
    • I have been using Unit Test Generator for quite some time, after I have upgraded if I try to generate unit tests from context menu, menu doesn't contain list of my existing test projects. Is this normal behavior ? Is there any way so I can "hack" my list in until you check this issue ?
      
      Thanks
  • Add Assert.Inconclusive to method body template
    1 Posts | Last post February 11, 2014
    • I would like to have the default methods be "Inconclusive", so that I can distinguish them from failed/succeeded test in the test window. 
      Thanks.
1 - 10 of 33 Items