An incorrect rule configuration in an application can cause delays in case processing. To avoid configuration errors such as incorrectly routed assignments, unit test individual rules as you develop them. To expedite future rules testing, you can create reusable test cases from the unit test.
You can test a rule with test data that you provide by clicking Actions > Run on the rule form toolbar. Some rule types, such as binary file rules, Pega does not provide an option for unit testing. If the rule cannot be unit tested, the Run option is not available.
The appearance of the Run Rule window varies across rule types, so how you run a rule varies by its type. In general, however, the rules run using data from a test page that you define for the test.
Tasks involved in defining the test page include the following.
- Selecting a method for creating the test page – You can copy values from a thread of an existing clipboard page to the test page, create a new test page, or reset the values of an existing test page. For more information about clipboard pages, see Clipboard tool.
- Applying data transforms – For a reusable and expedited method of making decisions and calculating values, you can apply data transforms to set values for the test page. For example, to unit test a decision table, you can create a data transform to provide values for the properties evaluated by the table, rather than manually entering values when you run the rule. For more information about data transforms, see Data Transforms.
- Manually entering test data – In some cases, you can manually enter values to use. If you enter values for a test, the values you enter override values on the test page.
- Specifying how service rules run – For services, you also specify whether the service rule is to run in your session or is to run as a newly created service requestor. If the service is configured to run as an authenticated user, you are prompted for a user name and password.
When you run the rule, the system uses rule resolution. If you unit test a rule, and there is a higher version of the rule, the system runs the higher version.
After you run the test, you can also convert the test to a reusable test case that you can run at any time. For more information about using unit test cases, see Understanding unit test cases.
- Unit testing UI rules
Types of UI rules include harnesses and sections.
- Unit testing data model rules
Types of data model rules include data pages and data transforms.
- Unit testing decision rules
Decision rules are used for configuring decision data flows for actions such as loading customer data, executing a decision strategy, and writing results into interaction history. Types of decision rules include decision tables, decision trees, when rules, map values, collections, and declare expressions.
- Unit testing process rules
Types of process rules include flows and case types.
- Unit testing report rules
Report rules include report definitions.
- Unit testing technical rules
Types of technical rules include activities.
- Unit testing parse rules
- Unit testing service rules
- Clipboard pages created by the Run Rule feature
After running a rule, you can open the Clipboard tool and examine the output as it appears on the resulting clipboard pages. The Run Rule operation creates the following pages: