What Was I Thinking?

Follies & Foils of .NET Development
posts - 91 , comments - 344 , trackbacks - 0

Launching ASP.NET WCF Service Hosts for WCF Unit Tests

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.

Print | posted on Tuesday, August 10, 2010 10:29 PM | Filed Under [ Visual Studio ]

Feedback

Gravatar

# re: Launching ASP.NET WCF Service Hosts for WCF Unit Tests

thanks for share,
I will use this tips if i have a problem
8/10/2010 8:47 PM | gifts for techies
Gravatar

# safe food handling

If you are using the Visual Studio Unit Testing framework, in your unit test .... your last little bit on the error message helped me solve another problem... thanks! ... Developerslog.net » Testing WCF services using MSTest said and Here is helper class I have written as a facade for service host. ... safe food handling
8/10/2010 10:19 PM | Peter Pang
Gravatar

# re: Launching ASP.NET WCF Service Hosts for WCF Unit Tests

Solution contains a number of projects including a contract, service, host, and unit test assemblies. People host their services in ASP.NET web sites, which they run via my dev web server and then IIS when they deploy to my production and test environments.
8/11/2010 8:20 AM | Job Vacancies UK
Gravatar

# re: Launching ASP.NET WCF Service Hosts for WCF Unit Tests

All fashion brands and new styles.
8/8/2011 3:33 AM | mvphats
Gravatar

# re: Launching ASP.NET WCF Service Hosts for WCF Unit Tests

This is the main reason that we can supply such low price to customers. Therefore, the prices are significantly lower than what you would find at the local mall or even other online stores.
11/18/2011 3:24 AM | Cheap Snapback Cap
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: