Workflow TV - How to test activities and workflow services with XamlInjection

Sign in to queue

Description

In our last episode I showed you the Contoso HR sample application.  The Submit Application workflow coordinated database updates, sending of email and multiple web service calls.  How can you unit test a workflow like this?  You don't want to update databases and send email when testing but you want to be sure that the conditions and correlation queries are correct.

The WorkflowTestHelper project now features XamlInjection which allows you to inject mock activities into the XAML when testing.  In this episode I'll show you how I tested the Submit Application workflow using XamlInjection.

Ron Jacobs
blog        http://blogs.msdn.com/rjacobs
twitter    @ronljacobs

What do you want to see on endpoint.tv?

 

Tags:

WF, WF4

Embed

Download

Download this episode

The Discussion

  • User profile image
    Mazric

    Its good to see that you guys are making the framework easier to test, it would be great to see you guys work with the third party Mocking guys to enable some of this functionality rather than rolling your own mocking framework.

    There seem to be a bit of fragility in the test two with magic strings.  But looks good.

    Cheers

  • User profile image
    rojacobs

    Thanks for the feedback - I hear you. We want to provide ways to work with exisitng mocking frameworks when possible. XAML based workflows are in a special category of thing that other mocking frameworks can't really help you with.  Of course once you cross over into the code of an activity then you can always mock at that level with whatever you like

  • User profile image
    alex

    I tried to do the same, but my activity is a slightly more complicated than yours: it contains reference to custom type MyType. I added reference to the type in a unit test project. Nevertheless when I run worflow using your WorkflowInvokeTest class I got an error message: "Cannot create unknown type '{http://schemas.microsoft.com/netfx/2009/xaml/activities}Variable({clr-namespace:Activity_2}MyType)'. So looks like your class works only for simplest cases when there is no references to any custom activity

Add Your 2 Cents