Where is the “Create Unit Tests” selection?

前端 未结 9 1359
情歌与酒
情歌与酒 2020-11-30 19:25

I have installed the new Visual Studio 2012 Ultimate.

I have created a Test Project with my solution and it contains some default unit tests. However right clickin

9条回答
  •  -上瘾入骨i
    2020-11-30 19:45

    The answer of intrueder didn't work for many users. When I enter UT in a command window, I sometimes had the following

    >UT
    Command "EditorContextMenus.CodeWindow.CreateUnitTests" is not available.
    

    But sometimes it worked for the same solution, so behavior seemed to be intermittent.

    With a help of Dawa Law's post “Create Unit Tests… Function Not Available Or Disabled" I found that during  each  Visual Studio session  you need to create one test class manually before wizard will be available.

    If you have an existing Unit Test project in the solution,

    At Solution Explorer, right click the Unit Test project –> Add –> Unit Test… 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.  Note: You may delete the created Unit Test class file (UnitTestX.cs) as it is used to trigger the function.

    If you do not have an existing Unit Test project in the solution, you need to create it before adding a manual class:

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

    The Dawa Law's post “Create Unit Tests…” Function Not Available Or Disabled has snapshots to illustrate each step.

    Note, that VS 2012 Create Unit Tests Wizard support generation tests for public methods only, when in previous version private methods were also supported.

    .

提交回复
热议问题