RSS
Facebook
Twitter

Monday, December 08, 2008

How to convert a .NET class library to MS-Test project

In the past I used NUnit for all my unit testing needs it was free and worked fine. Creating a test class all I needed to do was to create a class library (dll) and add the needed attributes and start writing my tests.

Now I use Microsoft's testing framework that shipped with Team System as a part of my unit testing solution and every now I make the mistake of creating a class library instead of a Test Project. This time adding MS-Test attribute (TestClass) doesn’t help – Visual Studio doesn’t recognize the test and I can’t run it.

In case you make the mistake of creating a class library instead of a test project you can do one of the two things:

  1. Delete the project and re-create it
  2. Read below…

To convert a class library to Test project follow these four simple steps:

  1. Unload the project (.prj) file and then open it for update.
  2. add the following line to the project
    C# - <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    VB - <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
  3. Re-load the project back
  4. Run you (now working) tests

 

Simple isn’t it?

2 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...