Running Unit Tests from the Flow Designer

Last Updated: 08/12/2016 Introduced in Verision: 2.0

The Unit Tester organizes test data and scenarios. Unit tests can check for flow success, failure, errors or lack of errors. To manage unit tests, open a flow in the Flow Designer and select the Debug Flow link. Unit tests can be created, edited or deleted in the resulting Flow Unit Tests pop-up.

Note that in Decisions version 3.5 and above, you’ll need to click the Test Flow link rather than Debug Flow.

3.5 Test Flow Shot

Example

Our example flow will add 10 to any number and output the result. For this example, we will define three test scenarios: one where the expected output matches the actual output (Pass), another where the expected output does not match the actual output (Fail), and a third where the test passes, but it is expected to fail.

runAllTestsResult

 

We will begin in a Designer Folder by clicking the Create Flow button.

createFlow

 

In the resulting New Flow pop-up, we will name our new flow “Addition Flow” and click OK to open it in the Flow Designer.

nameFlow

 

First, we will select the Start Step of our flow and, in the Flow Data section of the Properties tab, click the Add button.

addFlowInputs

 

In the Edit object pop-up, we will define an input called “Number” with a type of Int32.

NameNumber

 

Next, we will add 10 to our Number input. We will find the Add component in the Toolbox tab, under the Data > Numbers category.

dragAdd

 

In the Mapping Editor, we will map Number to value1 and define value2 as “10”.

mappingToAdd

 

Next, we will connect the Add component’s Done outcome to the End Step and select the End Step. In the Properties tab, under the Output section, we will click the Add button.

flowCompleted

 

In the resulting Edit object pop-up, we will define an output called “NumberOut” with a type of Int32.

addNumberOutForOutput

 

Next, we will map the output of the Add component to NumberOut.

mappingForOutput

 

This completes our flow, so we will click the Debug Flow link.

Remember that in version 3.5 and above, you’ll need to click Test Flow to debug the flow.

flowFinished

 

Because we don’t have any unit tests defined, the first pop-up will provide us with the fields to define our first test. We will call our first test “Successful Test” and set Test Result to Pass. Under Expected Output Data, we will set NumberOut to “15” and under Input Data, we will set Number to “5”, and then click Save.

successfulTestPreset

 

With the creation of our first unit test, we can now run it and any additional tests we would like to run.

firstTestCreated

 

Next, we will create our second test. We will click the Create New link and, in the resulting pop-up, define our failing test. We will call it “Failed Test” and set Test Result to Fail. Under Expected Output Data, we will set NumberOut to “25”. Under Input Data, we will set Number to “5”. Then, we will click Save.

createFailTest

 

Our third test will be called “False Fail”. We will set Test Result to Fail, but define NumberOut as “15” and Number as “5”, and then click Save.

createFalseFailTest

 

To run our tests, we will click the Run All button. Our first two tests will have a Successful result. The third will fail because it expects a failing result, but instead gets a passing one. To remove, modify or run a test individually, we can use the three buttons on the right side of each unit test entry.

runAllTestsResult

 

Additional Resources