Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Creating unit test cases for rules

Updated on April 8, 2022

For most rules, you can create a reusable test case by converting a unit test to a test case, configuring case details, and then defining expected test results with assertions (test conditions). When the test case runs, the test results are compared to the expected results defined for the rule’s assertions. If the test results do not meet the defined assertions, then the test fails.

Before you begin: Unit test a rule and convert the test run into a test case. For more information, see Unit testing individual rules.
  1. Optional: To modify the rule or class that is used for the test, in the upper-right corner of the Definition tab, click the Gear icon, select the rule or class and then click Submit.

    If you are testing a strategy rule, then the componentName and pzRandomSeed parameters are also displayed. If you change either of these parameters, the test case does not return the expected results.

    • componentName – The name of the component (for example, Switch) that you are testing.
    • pzRandomSeed – An internal parameter, which is the random seed for the Split and Champion Challenger shapes.
  2. Optional: To prevent the test from being run as part of a test suite or from a REST service, on the Definition tab, select the Disable check box.
    The test case will be run only when you click ActionsRun.
  3. In the Expected results section, add assertions that define the expected results of the test. For more information about creating assertions, see Assertions.
  4. On the Setup & Cleanup tab, configure the actions to perform and the objects and clipboard pages to be available before and after the test runs. You can also clean up the clipboard after the test is run by applying additional data transforms or activities. For more information, see Setting up your test environment.
  5. Click Save.
  6. In the Details dialog box, enter a label that identifies the test case. The test case identifier is generated based on the label and cannot be modified after it is saved.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us