Monday, 9 June 2008

Changing a Class Library Project to a Test Project

I was moving some unit tests between assemblies today so that we could isolate some smoke tests from the more scenario type watin tests and for some reason MS Test wasn't picking up the tests contained within my new assembly.

It then dawned on me I hadn't created a Test Project using  the File | New | Project wizard, I had created a Class Library instead. So I simply needed to change the project type of the new assembly, I searched high an low for a way to do this in VS2008 with no luck, if anyone can point me in the direction of doing this via the IDE I would be grateful.

image

Anyway, I changed the project type the old fashioned way by editing the XML, select the Edit Project File option from the context menu on an existing Test Project, in the XML look for something that looks like this :

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



Copy this, then go to your Class Library project select the Edit Project File option on the context menu and insert the project type guid xml section. Next just reload the projects back into VS2008 and you will have all of the unit tests from the Class Library assembly available to run.

1 comment:

Anonymous said...

thanks a bunch mate, that really helped!