locked
How can I make VS understand that a project is a test project?

    Question

  • I have a project that was not created as a test project. But it was running tests in a very unit test like way, so I added using Microsoft.VisualStudio.TestTools.UnitTesting; to each source file along with the apropos [Test*] attributes so that I could run the unit tests from VS. However, VS doesn't recognize the tests. If I choose Test.Windows.TestView, my tests are not showing up there. Is there a way to get VS to recognize these tests?

    Thanks...Rick

    Thursday, June 8, 2006 10:09 PM

Answers

  • Hi Rick,

    There are two ways to solve the problem. 

    1. Locate your project file (e.g. .csproj or .vbproj) on the file system, open it using a text editor. You will notice it is in XML format. Insert the following line (child node) into the existing <PropertyGroup> </PropertyGroup> (parent node) if your test code is in C#

    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

    If your test code is VB, you should use the following

    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>

    After you save the project file and reload it in VS, Test View window should show the test methods in your project if they are created correctly.

    Please note C++ project use ProjectTypes attribute to identify the test project. To find out the attribute, just create a new C++ test project and open the project file using a text editor. Copy the attribute and its value and add it to your regular project file, then Test View window will recognize it as a test project.

    2. If you prefer doing it from the VS UI, you can add a new Test Project to you solution, add reference Microsoft.VisualStudio.TestTools.UnitTesting.dll if it is not in the references list. Move the test class from your old project into the test project

    Please let me know how it goes.

    Thanks,

    Christine Zhao

    Friday, June 9, 2006 12:32 AM

All replies

  • Hi Rick,

    There are two ways to solve the problem. 

    1. Locate your project file (e.g. .csproj or .vbproj) on the file system, open it using a text editor. You will notice it is in XML format. Insert the following line (child node) into the existing <PropertyGroup> </PropertyGroup> (parent node) if your test code is in C#

    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

    If your test code is VB, you should use the following

    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>

    After you save the project file and reload it in VS, Test View window should show the test methods in your project if they are created correctly.

    Please note C++ project use ProjectTypes attribute to identify the test project. To find out the attribute, just create a new C++ test project and open the project file using a text editor. Copy the attribute and its value and add it to your regular project file, then Test View window will recognize it as a test project.

    2. If you prefer doing it from the VS UI, you can add a new Test Project to you solution, add reference Microsoft.VisualStudio.TestTools.UnitTesting.dll if it is not in the references list. Move the test class from your old project into the test project

    Please let me know how it goes.

    Thanks,

    Christine Zhao

    Friday, June 9, 2006 12:32 AM
  • The first solution took care of it. Thanks so much!
    Friday, June 9, 2006 4:33 PM
  • Hi

    I am not able to open sample Nunit cs project file in Visual Studio 2005 . I tried to create a new cs project file and add reference to Microsoft.VisualStudio.TestTools.UnitTesting but cold not find it ..

    Is this reference available only for VSTS or am I  missing something.Please Help.

     

    Thanks

    Swapnil

     

    Wednesday, November 8, 2006 5:38 AM