Microsoft Developer Network > 포럼 홈 > Visual Studio Team System - Testing > How can I make VS understand that a project is a test project?
질문하기질문하기
 

답변됨How can I make VS understand that a project is a test project?

  • 2006년 6월 8일 목요일 오후 10:09RickKr 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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

답변

  • 2006년 6월 9일 금요일 오전 12:32Christine Zhao - MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    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

모든 응답

  • 2006년 6월 9일 금요일 오전 12:32Christine Zhao - MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    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

  • 2006년 6월 9일 금요일 오후 4:33RickKr 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    The first solution took care of it. Thanks so much!
  • 2006년 11월 8일 수요일 오전 5:38Swapnil2006 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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