My solution contains a number of projects; including a contract, service, host, and unit test assemblies. I host my services in ASP.NET web sites, which I run via my dev web server (cassini), and then IIS when I deploy to my production and test environments. My start up project is the Host project, so when I press F5, my service host starts and my services become available.
When I want to unit tests my WCF Services however, the service host doesn’t start. I’ve specified the Host Project to Always Start When Debugging = True. And yet, when I attempt to debug my unit tests, my host doesn’t start.
I’ve discovered a work-around. This work-around solves the problem of DEBUGging unit test, but not RUNning unit tests.
Here’s my work-around;
Make sure the Host project has Always Start When Debugging = True. and Set the Visual Studio Startup project to be something other than the Host project. When you debug, an instance of the service host will start up.
I haven’t found a solution for RUNNING a unit test and spinning up the service host yet. I would have thought the AspNetDevelopmentServer attribute would have worked, but it (stupidly) selects a random port. WOW.. NICE FEATURE!
Hope this solves, in part, your unit test hosting problems.