About Unit Testing & Debugging
  • 18 Jan 2022
  • 3 Minutes to read
  • Dark

About Unit Testing & Debugging

  • Dark


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 provide a suite of helpful tools through Unit Tests and the Debugger, which makes accurate and efficient methods of testing available. 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. 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.

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. Version 7 of Decisions introduces the Global Debugger, which runs debugging tests in the background system-wide, even while the administrator is interacting with the Decisions environment. 

Unit Testing & Debugging

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 on the right, 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 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 System > Designers > Unit Test Management.

To find the Data Samples folder, navigate to System > Designers > Toolbox Customization > Data Samples

Configured Unit Tests and Data Samples are available in both of these folders with managing actions. 

Was this article helpful?