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. For 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 by 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 that 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
Unit test UI rules, such as harnesses and sections.
- Unit testing data model rules
Unit test data model rules, such as data pages and data transforms.
- Unit testing decision rules
Unit test decision rules, such as tables, decision trees, when rules, map values, collections, and declare expressions.
- Unit testing process rules
Unit test process rules, such as flows and case types.
- Unit testing report rules
Unit test report rules, such as report definitions.
- Unit testing technical rules
Unit test technical rules, such as activities.
- Unit testing parse rules
Types of parse rules include parse delimited rule, parse XML rule, parse structured rules.
- Unit testing service rules
Unit test service rules such as, email, Java, MQ, SAP, and SOAP rules.
- Viewing clipboard pages created by unit testing a rule
After running a rule, you can open the Clipboard tool and examine the output as it appears on the resulting clipboard pages.