Part 1: Testing custom WF activity using SpecFlow for Warewolf

Warewolf currently makes use of the Windows Workflow Foundation (WF) engine to execute services. We make use of custom activities for all the current tool connectors. In some cases these make use of built-in WF activities.

During the development of Warewolf we needed to find a way for a non-developer member of the team to define specifications for various parts of the system.

To achieve this, we chose SpecFlow, an established Behaviour Driven Development (BDD) tool. It gave us the language and framework that supported developers and non-developers alike.

Using SpecFlow we could have our Tester, for example, define the specifications of each tool inside Warewolf. He could then execute the specification to determine if the tool was working correctly at any given time.

It also gave him the ability to create bugs related to these specifications that were not passing. Hence, we were able to find bugs that previously we would not have found until the tool was used in that way. This technique also allowed us to specify the debug input and output for each tool.

So let’s see an example of a SpecFlow specification:

 

Scenario: Assign a value to a variable
Given I assign the value 10 to a variable "[[var]]"
 When the assign tool is executed
 Then the value of "[[var]]" equals 10
 And the execution has "NO" error
 And the debug inputs as
 | # | Variable | New Value |
 | 1 | [[var]] = | 10 |
 And the debug output as
 | # | |
 | 1 | [[var]] = 10 |

As you can see the above specification defines:

  • the function of the Assign tool connector,
  • the fact that no error occurs, and
  • the debug inputs and outputs that will be produced when the tool connector is executed.

 

Scenario: Assign the value of a negative recordset index
Given I assign the value 10 to a variable "[[rec().set]]"
 And I assign the value [[rec(-1).set]] to a variable "[[var]]"
 When the assign tool is executed
 Then the value of "[[var]]" equals ""
 And the execution has "AN" error
 And the debug inputs as
 | # | Variable | New Value |
 | 1 | [[rec().set]] = | 10 |
 | 2 | [[var]] = | [[rec(-1).set]] = |
 And the debug output as
 | # | |
 | 1 | [[rec(1).set]] = 10 |
 | 2 | [[var]] = |

The example above shows a specification where an error occurs. An improvement that can be made to this specification is to define the actual error message that will be produced.

As can be expected there is a fair amount that goes into actual execution of the specification, hence I direct you to the Warewolf open source project where all the code for running the specifications can be found, as well as specifications for the other tool connectors.

Look out for part two, where we use SpecFlow to specify the execution of multiple tool connectors together as a service.

 

 

FacebookTwitterLinkedInGoogle+RedditEmail

2 Comments

  1. Henry

    Hi,

    I have forked the repo and have the code. Which project/solution contains the specflow examples shown above?

    Thanks

    P.S please make this comment box taller (single line is bit hard to use) :).

Leave A Comment?