Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Unit Testing Workflow Foundation

Unit Testing Workflow Foundation

This item in japanese

Windows Workflow Foundation offers some powerful capabilities for those working with data flow style architectures. But these capabilities come at a cost. Unlike traditional batch processing applications, Windows Workflow Foundation does not lend itself to automated testing.

There are several attempts at making testing more palatable with mixed results. Ron Jacobs tests activities using a custom activity and workflow. Some like Maurice de Beijer don't agree with that approach,

Most people consider unit testing of custom workflow activities to pretty much impossible. Sure you can create a dummy test workflow containing your new activity, new up a WorkflowRuntime, create a WorkflowInstance and start it. But just think about all the dependencies here with the extra dummy workflow and the complete WorkflowRuntime with all its dependencies. Hardly a unit test for an activity but more like an integration test. Now there is nothing wrong with integration tests, they are very useful and necessary, but they do not give the speedy and dynamic test coverage you expect and need from a unit test.

Much of the problem with performing unit tests is that ActivityExecutionContext is sealed. Maurice gets around this by using TypeMock to sidestep this restriction.

Unfortunately, both of these are still far more complex than what is required when developing dozens if not hundreds of automated tests. Hopefully future developments will change this.

Rate this Article