This post describes a unit testing library for testing Windows Workflow Foundations.It is not a framework like HarnessIt, NUnit, or MsTest. Rather it’s a library that can be used in conjunction with any of these testing frameworks.
Download the library with sample test project here:
Kennedy.WorkflowTesting.zip (216 KB)
You can also just jump to the code.
First a Little History:
Last September I posted this teaser entitled Unit Testing Coming to a Workflow Near You. My intention was to post this article that you’re reading now shortly thereafter when I got some free time to polish things up. In that previous post, I highlighted what I could determine to be the current state-of-the-art with regard to unit testing workflows, circa September 2008.
I’m pleased to announce that MSDN Magazine just published my Windows Workflow article entitled
“ASP.NET WORKFLOW: Web Apps That Support Long-Running Operations”
I hope you find it useful and interesting.
[Update: See the follow up post "Significant Advances in Unit Testing Windows Workflow"]
If you’ve been working with Windows Workflow, you’ll find it has some cool features for orchestration, long running operations, state machines, etc.
However you won’t find very much support for Test Driven Development (TDD) or unit testing in general. In fact the architecture that makes Windows Workflow powerful (strict separation of workflow, activities, and the host for example) really gets in the way of unit tests.
There has been some work done on unit testing Windows Workflows. Here’s some links:
These are all very creative solutions. But, personally I find all of them more complex than they need to be. So in the near future I’ll be putting together some libraries and samples on unit testing Windows Workflow. I think you’ll find them far more powerful and at the same time simpler than anything out there.
So until I get that finished, if you have any feedback or considerations on unit testing Windows Workflow I’d love to hear it. If there are other articles I’m missing, please post them in the comments.
I think you’re going to like this…