“Create Unit Tests…” Function Not Available Or Disabled

If you followed my two blog posts previously (Create Unit Tests Workaround and Solution), you may found out at some point of time, the function of “Create Unit Tests” wizard is disabled on your next attempt to launch the Create Unit Tests wizard.

The following issues were encountered:

  1. When you used Keyboard Shortcut workaround, the Create Unit Tests Wizard does not appear.
  2. You may receive the following error while using the Command Window workaround:
    Command "EditorContextMenus.CodeWindow.CreateUnitTests" is not available.

    Command "EditorContextMenus.CodeWindow.CreateUnitTests" is not available.
    Command “EditorContextMenus.CodeWindow.CreateUnitTests” is not available.
  3.  Right-Click “Create Unit Tests…” menu is disabled or grayed out when you use either solutions.

    "Create Unit Tests..." menu disabled
    “Create Unit Tests…” menu disabled

This is a known issue and the below solution will solve the problem.

Solution

If you have an existing Unit Test project in the solution, you may skip to Step 3.

  1. Go to File –> Add –> New Project

    Add New Project
    Add New Project
  2. In the Add New Project window, select Installed –> Visual C# –> Test –> Unit Test Project. Give it a meaningful name and click OK.

    Add New Project window
    Add New Project window
  3. At Solution Explorer, right click the Unit Test project –> Add –> Unit Test…
    Add Unit Test class
    Add Unit Test class

    [adrotate banner=”1″]

  4. Now, right click on a method and “Create Unit Tests…” will appear.

    Hey, it's there now!
    Hey, it’s there now!
  5. This will create a new unit test class and trigger Visual Studio that an existing Unit Test class is available, thus enables Create Unit Tests wizard.
Create Unit Test wizard
Create Unit Test wizard

Note: You may delete the created Unit Test class file (UnitTestX.cs) as it is used to trigger the function.

Have fun Unit Testing!

26 thoughts on ““Create Unit Tests…” Function Not Available Or Disabled

  1. Maybe ReSharper is somehow messing up this solution, but I’m still not getting the wizard after trying to add a test to an existing test project in our solution. (Per the above fix.)

    • Scott,

      If you tried this workaround, do you get Command "EditorContextMenus.CodeWindow.CreateUnitTests" is not available. ? Besides, do verify the steps above to confirm that you selected unit test project, and added unit test class.

      I will download and test with Resharper to reproduce the problem when I have time to look into it.

      Dawa

      • Yes, I definitely selected my existing unit test project, right-clicked and added a unit test, and it didn’t help. I did that command window stuff and it works, but I still / again don’t have the context menu item. Still, at least I can spin ’em up via the command window deal.

      • Well HOT DOG! It FINALLY worked / stuck! I just did the “2nd way” solution which looked like it wasn’t going to work, then I noticed that Create Unit Tests… was NOT grayed out! So, I clicked on it and I got a dialog about how it will only generate tests in non-test projects (which I hadn’t realized I was it at the time). So I went to another project, put my cursor onto a method name and selected the Create Unit Tests… item on the context menu and bewm, up came the wizard dialog! Whooo Hoooo!

  2. Hi Dawa,
    Thanks for the post. I was able to get “Create Unit Test” option.
    But the problem is, in the Create Unit Test window (screenshot in step 4), I am not able to expand the project.
    It gives me error saying something like:
    Assembly reference cannot be resolved

    I found on some of the blogs that the target framework should be same for all the project in order to avoid this error.
    But for store apps, I cannot set target framework 🙁

    If I try “Create Unite Test” option in some other project which uses same target framework as that of Unit Test Project, the option works fine and code is generated.

    Do you know how to make it work for store apps?

  3. I’m german. My english is mediocre and I didn’t figure out what to do 🙁 Especially, this sentence didn’t make any sense to me: “4.This will create a new unit test class and trigger Visual Studio that an existing Unit Test class is available, thus enables Create Unit Tests wizard.”

    What Triggers what?! When I created a new unit test like step 3 suggested, I didn’t get the “create unit test wizzard” anywhere 🙁

    • Sorry for the confusion. All you need to do now is just right click on any method, “Create Unit Tests…” will be available.

      Dawa

  4. Dear Dawa,

    Your posts are very helpful but I am trying to unit test SQL Server 2012 Stored Procedures in Visual Studio 2012 Ultimate version and I don’t see the “Create Unit Tests” menu even after trying everything you said. I don’t see this menu when I right click on a stored procedure. What’s going on? Please help. Thank you.

    Best regards,

    Ali

Leave a Reply