Running Unit Tests on a FlowLast Updated: 05/02/2018 Introduced in Version: 2.0
You can run unit tests on flows from the Flow Designer. Unit tests run like regular tests in the debugger, but they let you define boilerplate flow input data (so you don’t have to enter it manually each time you want to run a test). This assumes your flow has input data; if not, the unit test option will not appear in the debugger. Using a unit test is especially helpful during development of a flow that uses many input data.
Unit tests also let you define an output rule for evaluating flow output data. Again, this assumes your flow has output data; if not you can ignore it. This lets you evaluate whether your flow is returning the output data you expect when you’ve run it with a certain set of input data.
To run a unit test on a flow open in the Flow Designer, click Debug Flow in the top bar. If the flow has input data, you will be prompted to enter it in the right panel and given the option to save it as a unit test input.
Our example flow will add 10 to any number and output the result. For this example, we will define two test scenarios.
In the Decisions Studio, we will begin by creating a new flow in a Designer Folder. For more information on creating a flow, see Creating Your First Flow. For this example we name it AdditionFlow.
First, we will click the green Start Step of our flow and, in the Properties tab on the right under Flow Data, click Add New.
In the Add Flow Input Data pop-up, we define an input called “Number” with a type of Int32 and click OK.
Back in the Flow Designer, in the Steps tab on the right under Data > Numbers, we drag an Add step onto the workspace.
We configure the mapping editor as follows:
Next, we will click and drag the outcome path of the Add step to the End Step.
When we test this flow we will want to see and be able to evaluate the output data from the Add step. To do this we need to create output data.
To do this, click on the End Step and, in the Properties tab on the right under the Output section, click Show Editor.
In the resulting Data Definitions pop-up, we create define an output called “NumberOut” with a type of Int32 and map our original data – “Number” – to it. Click Close when finished.
The resulting Rule should say the following to have a Failed Test returned as Passed:
To run our tests, we will click the Run All button. Our first two tests will have a Successful result. To run a test individually, we can use the play button on the right side of each unit test entry. To remove or modify, use the right hand side field.