Verifying validity of Workflow Service in Unit Test

Introduction

At work we’ve been having a little bit of trouble verifying that a Workflow Service still “works” after we change something. This is because our custom activities are in a separate assembly. When we change the activities and run MSBuild, we’ll notice that the unit tests still work and that the workflow still compiles. Only after we deploy the service and try to hit it, do we see errors that indicate that the workflow can not be instantiated, for instance because we removed a parameter from an activity. We need some kind of regression testing to prevent this.

To solve this, we now instantiate the workflow in a Unit Test as I will describe in this post.

Problem description

Suppose I have a very simple CodeActivity that takes two values and multiplies them:

public sealed class CodeActivity1 : CodeActivity
{
    public InArgument Input { get; set; }
    public InArgument Factor { get; set; }
    public OutArgument Result { get; set; }

    protected override void Execute(CodeActivityContext context)
    {
        var input = Input.Get(context);
        var factor = Factor.Get(context);

        var result = input*factor;

        Result.Set(context, result);
    }
}

I then have a Workflow Service which calls this activity with a value for Input that it gets from a service call, and a constant value of 3 for the Factor:

workflowservice1
Continue reading

Pretty test output with the Turn gem

Have you ever been annoyed that when you run tests, you only see periods, E’s and F’s; not being able to see what actually went wrong until all the tests were done?

I found this pretty gem last week, thanks to some nice people in #rubyonrails. It’s called Turn, and I am unable to find a repository for it anywhere. What it does, is update your test output as follows:

Without Turn:

Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
Started
........
Finished in 0.339899 seconds.
8 tests, 8 assertions, 0 failures, 0 errors

With Turn:

Loaded suite
/usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake/rake_test_loader
CourseInstanceTest

test_truth                                                            PASS
CourseTest

test_truth                                                            PASS
# some output removed here
==============================================================================
pass: 8,  fail: 0,  error: 0
total: 8 tests with 8 assertions in 0.373991 seconds
==============================================================================

Continue reading