Testing WCF Service Apps (Part 0 of 4)

Shout it

When you are writing automated tests for your application, it is important that the tests do not rely on the file system or external services.  The only problem is that when you write applications using WCF, you are writing code that relies on external services.  It is very tempting to create service references in your test DLL and test against them, but please refrain.  There is a better way, I promise!

This series will focus on testing every part of your application — including round-trip functional tests — without employing the WCF framework directly.  We need to remember that the WCF framework is code that we do not control.  We need to trust that it does what it claims to and focus on our code directly.  In addition, the WCF framework is configurable via XML files, so we don’t need to worry about having configuration working directly.  Writing tests for your code needs to be about your code, not the WCF framework.

So, let’s look at the application that I am using in this series.  I have a WCF service named RecipeBoxService that stores and retrieves recipes.  The service is used as a back end for many possible clients: WinForms, ASP.NET, MVC, Silverlight, etc.  In this series, I will be writing a data mining application to demonstrate the testing techniques.


This post is just the introduction.  The actual parts will be laid out something like this:

  1. Testing the WCF service
  2. Testing the synchronous client
  3. Testing the asynchronous client
  4. Functional testing front-to-back

Leave a Reply