Wednesday 31 October 2007

Turning a c# project into a test project

Ever added a C# project by accident when you meant to add a Test project? And only realized after writing a test, adding all the references and not finding it in test manager?

I have; and I can never remember exactly how to fix it. I'll post the steps here so I can find it in the future, and maybe help other people with the same issue.

Test projects are aggregate projects (language and type) and these properties are set under an element in the project file called projecttypeguids.

A test project looks a little like this:

<propertygroup><configuration condition=" '$(Configuration)'== '' ">Debug</configuration>
...
<projecttypeguids>{guid};{guid}</projecttypeguids>
</propertygroup>

So:

  1. Right click on the project in question and choose "unload project".
  2. Right click on the project again (it should now be grey and look something like [project name](unavailable) and select Edit [project name].
    1. for c# add:
      <projecttypeguids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</projecttypeguids>
    2. for vb add:
      <projecttypeguids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</projecttypeguids>
  3. Right click once again and choose "Reload project"

Hope this helps someone out there.

    No comments: