- 20 May 2022
- 1 Minute to read
- Print
- DarkLight
Debug Rules
- Updated on 20 May 2022
- 1 Minute to read
- Print
- DarkLight
Overview
Rule logic can be tested using the Debugger built into the Rule Designer. Test information can be entered into the debugger for a one-time evaluation against the Rule or it can be saved as a Unit Test. It is common practice to create a Unit Test that will render both a true and false scenario for accuracy purposes.
This article will be separated into two parts, covering how to create Sample Data and Unit Tests for Rules.
This example uses a Rule that checks to see if the country is the US, and either the state is in a list or the age is between 20 and 40.
The Rule will receive values for each piece of input data; Country [String], State [String], and Age [Int32], which is evaluated against the conditions. The Debugger provides a place to enter sample data that correspond with the expected input data types.
Creating Sample Data
- Select the Debug button from the top Action Bar in the Rule Designer to test the logic.
- The first available function in the Debugger is to enter sample data in the INPUT DATA section. Here we can add the needed inputs for the Rule.
- Once the inputs have been added select START DEBUGGING.
- The information that is entered should be expected to either evaluate true or false. The result will be shown in the Debugger.
- Once finished, select the Save As Data Sample button to create new SAMPLE DATA.
- Select the Create Sample Type checkbox to create a new type or deselect and choose an existing type. Once finished, Save. New Sample data will appear under the SAMPLE DATA header on the left.
Creating a Unit Test
- The Save As Unit Test button or the Add New button under the INPUT DATA section can be used to create new Unit Tests. Typically Unit Tests are configured to contain sample data that will exercise both the true and false evaluation of the Rule.
- To create a Unit Test, provide a Test Name and some sample data to the [UNIT TEST DATA] section.
- The EDIT UNIT TEST RULE button can be used to configure additional conditions on specifically the true or false evaluation of the Rule.
- When either SAMPLE DATA tests or UNIT TESTS are available, select the play icon to automatically run the test with the pre-defined data, or use the Run All button to initiate all tests.