9

How to unit test the windows workflows?

Panos
  • 18,992
  • 6
  • 45
  • 54
user11039
  • 854
  • 2
  • 9
  • 17
  • 1
    Please specify your question and give an example, as it seems too broad right now. What are you looking for exactly? – Kena Oct 08 '08 at 13:41
  • I think Workflow activities are relatively testable. Here's an entry from my blog about unit testing Workflow activities: http://www.unit-testing.net/CurrentArticle/How-To-Write-Unit-Tests-For-Workflow-Activities.html – T123 Mar 06 '12 at 05:30
  • See similar question already asked: > [Unit/Automated Testing in a workflow > system](http://stackoverflow.com/questions/143183/unitautomated-testing-in-a-workflow-system) – Ray Oct 22 '08 at 16:44

3 Answers3

6

K. Scott Allen has posted this, which provides an approach to unit testing custom activities (although he says that he is not satisfied). A similar approach is presented by Ron Jacobs here and here.

Another approach is presented by Maurice here and here (he uses TypeMock as Will already mentioned).

Community
  • 1
  • 1
Panos
  • 18,992
  • 6
  • 45
  • 54
  • The Ron Jacobs articles are very promising, especially the second one which contains a sample solution showing how to wire-up the WWF runtime to host the unit tests. – Tim Long Aug 27 '10 at 03:12
4

Microsoft.Activities.UnitTesting.

A library of helper classes and activities designed to make unit testing of workflows easier.

Looks like there's a Channel 9 video for it on the downloads page, too.

TrueWill
  • 25,132
  • 10
  • 101
  • 150
  • @jlafay Have you found it possible to test the value of a variable in a workflow service? Please look at this [post](http://stackoverflow.com/questions/9672878/assert-the-value-of-a-wf-service-variable-during-a-unit-test) and let me know what you think. – Mike Perrenoud Mar 13 '12 at 14:51
3

MS dropped the ball on making workflows easily mockable and testable. If you want to do thorough tests on your custom activities you'll need to purchase a mocking framework that can mock sealed types such as TypeMock. Otherwise, you'll have to write your code around the limitations of Workflow.