views:

81

answers:

3

I know it is possible for VS 2008 to generate unit test code to test C# classes, but I cannot find the right sequence of mouse clicks to generate the code. Any help?

A: 

I have Visual Studio 2008 professional installed. I just need to right-click on a function or class name and select "Generate Unit Tests" from the popup-menu.

GrayWizardx
That option is not available to me. I am running VS 208 Professional Edition version 9.0.210022.8, and when I right click on either a class or a project containing only classes, there is no option to create unit tests. Any idea where this option may live?
Microsoft Visual Studio 2008 - Version 9.0.30729.1 SP, all relevant hotfixes installed. I did not do anything special, and according to the docs this is by-default behaviour in VS professional: ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vsetlt01/html/4e5d85db-2a9f-4f31-acc9-a2aebd14eac3.htm
GrayWizardx
A: 

For me, if I right-click a class in the editor, there's a Create Unit Tests option in the popup menu. (Near the top, just below the Organise Usings flyout.) I don't think I customised it so hopefully it's also there in the default menu layout...!

itowlson
That option is not available to me. I am running VS 208 Professional Edition version 9.0.210022.8, and when I right click on either a class or a project containing only classes, there is no option to create unit tests. Any idea where this option may live?
Hmm, it's possible the test components aren't installed. Do you see a Test menu in the main menu bar? If so you can get there via Test > New Test > Unit Test Wizard.
itowlson
You can check the installation status by rerunning the installer from Control Panel, selecting add/remove features and looking under Team System Developer Tools.
itowlson
+1  A: 

I don't think the generate unit test function of Visual Studio is available in the Professional version. You need Team Developer edition, Team Tester edition or Team Suite edition.

You may want to look into PEX instead. It works in Professional just fine.

Mark Ewer