- 05 Dec 2024
- 4 Minutes to read
- Print
- DarkLight
Debug Flows
- Updated on 05 Dec 2024
- 4 Minutes to read
- Print
- DarkLight
Overview
When a Flow is created in Decisions, it is important to make sure the Flow logic works properly before being used in a production environment. Decisions provides a suite of helpful tools through Unit Tests and the Debugger, which makes accurate and efficient methods of testing available.
The Debugger provides an interface where the Unit Tests can be executed as if at run-time and information becomes available for successes or failures on each step of the Flow. There is also the Global Debugger, which runs debugging tests in the background system-wide, even while the Administrator is interacting with the Decisions environment.
This document will walk through debugging using Unit Tests and Sample Data.
Unit Testing & Debugging
Unit Tests are saved configurations comprised of test values that correspond with the Flow Input Data. Unit Tests are inputs with assertions about what happens to them. These test values are sourced either from the Administrator at the time of saving the Unit Test, or from Sample Data (described below).
The following example uses a Flow that is set up to receive two decimals called Value1 and Value2 as input data. The Add step receives these values to calculate the sum, which is then shown in a popup.
In the Flow Designer, select the Data Samples tab on the left so that the Unit Tests and Sample Data sections appear. Use the Add New button next to Unit Tests to add a new one. The Edit Unit Test window contains a space to configure the Test Name and define the input values. The Test Result Evaluation Rule can be manipulated to return true/false results based on altered evaluations in the Rule. This Rule is created by default with Unit Tests, but it does not need to be modified for function.
The inputs in the Flow that will need a value are in the Input Data section of the Edit Unit Test window. The configuration for the Unit Test below has it so that Value1 will always be 10 and Value2 will always be 5 whenever the test is executed. These values can be modified later using the pencil icon next to the Unit Test name once it is saved.
Selecting the arrow or play icon next to the name of a Unit Test will immediately execute the test in the Debugger using the pre-defined values. While viewing the Unit Test results in the Debugger, select a step icon, and use the View Input/Output Data button to see what data values passed through the step.
Alternatively, select the Debug button from the top action bar to enter the Debugger. In the Debugger window, raw input data can be configured, then that data can be used to either save as a Unit Test or as Sample Data. The saved Unit Tests for this Flow will appear in the list on the left. Use the play button next to the name of the Unit Test to start that test in the Debugger.
Sample Data
Sample Data is a set of configured data of one or many types, that can be referenced by any Flow and used for mapping as long as the type matches. Sample Data functions similar to Unit Test data, but Sample Data is global for any Flow that expects input values of the same name and type. When a New Sample is added, use the Create Sample Type checkbox to make a new section of Sample Data labeled as the New Type Name. If a section already exists under Sample Data, use the dropdown list to select it when adding a new set. Once the Sample Data is created, it can be referenced in any Flow that uses Value1 and Value2 as input data.
Managing Unit Tests and Sample Data
Unit Tests and Sample Data can be executed, edited, and deleted from the Data Samples tab or the Debugger window within the Flow Designer. This data can also be accessed via their respective system folder within the Decisions platform by default.
To find the Unit Tests folder, navigate to Settings > Configuration > Data > Unit Tests within a Designer Folder.
To find the Data Samples folder, navigate to Settings > Configuration > Data > Data Samples within a Designer Folder.
Configured Unit Tests and Data Samples are available in both of these folders with managing actions.
Sampling Mode
By default, the Flow Debugger, Unit Tests and Sample Data are set to run in "Sampling Mode". In Sampling Mode, the Debugger will record the data (input data, output data, step info) only for five iterations out of all the iterations it is supposed to run. It will capture the data of the first two and last three iterations, respectively. It helps to reduce memory consumption and makes the debugger faster (in most cases) as we reduce communication between the server side and the browser.
There are two ways of accessing Sampling Mode; at the Project Level through Settings and through the Debugger.