Unit Testing (Advanced)

Last Updated: 01/04/2019 Introduced in Version: 3.5

Unit Tests can be used using various techniques within Decisions designer studio. Unit Test’s can be created using a flow and a rule to test data as it passes through. Advanced Unit Test’s have advantages that help to quickly and accurately check the data being passed through and provide a clear picture of what you may be looking to test. This document demonstrates advanced techniques of using Unit Test utility in Decisions designer.

Prerequisite: To start with Unit Test utility please go through Unit Tests Overview (Simple Flow) document first. This document demonstrates the advantages of using Unit Tests on Composite Data Types, Step Simulation Options, and Running Unit Test Rules before any step in the Flow.



Composite Data Types

Begin by starting from the flow designer. Select the Start Step in the Flow designer and choose Show Editor in the Properties Tab to add a new flow Input Data. In the Data Definitions Editor create a data Name and define the Type. For this example search for accounts in the search bar and select Account [DecisonsFramework].

Figure 1


Next, connect the Start Step to the End Step in the Flow and select Debug located on the top of the flow designer on the action panel to open up a Unit Test.

Figure 2

In the debugger add a New Unit Test by selecting Add New next to Unit Tests. 


Give the Unit Test a Name (CheckAccountField) and select the Input Data settings button on the right under Input Data.  Next, Pick or Define an existing Account (admin@decisoins.com)  add a description and select Define to save a close.

Add a second Unit Test and choose a different Input Data. This Unit Test is named CheckEmailTest and uses Account: user@decisions.com

Figure 5


Edit each Unit Test and create a rule that checks for  Account EmailAddress Contains Admin. The example sets up a rule that checks for admin in the account email address. Select Edit under the Test Result Evaluation Rule to add a rule to each Unit Test.

Figure 6


In the Rule designer write a rule that can evaluate any desirable field of the Composite Data Type. This rule will use the pick Email Address field from the Account input as the example. The Rule states: If the Account.EmailAddress Contains admin (if the Unit test passes the rule will evaluate true if the Unit Test fails the rule will evaluate false).


Figure 7


Select Run All to run all Unit Test’s created. Next, Save, close the Unit Test and navigate back to the Flow designer.

Figure 8



Select the End Step and under Data and  Output select Show Editor. Create a new data definition called (Account) and then choose String as the TypeUnder Inputs next to Account choose Select From Flow and then pick Account. 

Figure 9


In the Flow designer, select Debug. Next, to Unit Tests select Run All to run all Unit Tests. The results of the Unit Tests will display under Under Unit Tests, displaying which test evaluated as true or false (Figure 12).

Figure 10


This completes the example of setting up Unit Tests for Composite Data Types.



Step Simulation Options

In the Flow navigate to the Placeholder Step and in the Properties Tab Add Simulation Selected Paths. Under Outcome Definition and under Outcomes select Add New to Add a new outcome/pathway (Figure 11). 

Figure 11


Define the Outcome definitions in the editor (Figure 12).

Figure 12


Running a Unit Test on a specified step is called Step Simulation. Step Simulation can be specified on a step or on a specific direction in a flow. Start with the Unit Test Flow, add a Placeholder Step and connect the pathways (Figure 13).

Figure 13


Testing and Simulation (Use Simulation Behavior)

Each option that is checked under simulation behavior will run the flow with that behavior and on the selected pathway.

  • InDebugger: Run the test in the debugger on the selected pathway.
  • InProduction: Run the test at Production on the selected pathway.
  • InUnit Tests: Run the Unit Tests in the flow on the selected pathway.

Simulation Selected Path

  • Choose the path in the drop down to run a Unit Test or a Unit Test Rule.

Run Unit Test Rule

  • Checking the box runs a Unit Test Rule on a specific Test. The Unit Test Rule can be created by selecting edit underneath the specified Step. The Unit Test Rule runs before the step.


Figure 12

Begin in the Unit Test Flow then, select Run Unit Test Rule. Under Unit Test Rule select Edit to edit the rule. In the Flow, Name the test and pick Account. 

Figure 13


Next, build the Rule that will run on the Placeholder Step. 




In the Flow designer select Debug to open up the Unit Test options. Under Unit Tests on the left choose CheckAccoutFeild and then Run the Unit Test. 

Figure 15


If the Unit Test evaluates False the flow will stop in the debugger. If the Unit test evaluates True the flow will continue to deploy in the debugger.

Figure 16

This completes the example for advanced Unit Testing. 

Additional Resources