Skip to main content

Creating unit test cases for rules

Pega Community logo

Note: The following content, referenced from Pega Community, is included here to help you better achieve the module learning objectives.

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 – 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 Actions Run .

  3. In the Expected results section, add assertions that define the expected results of the test. For more information about creating assertions, see Defining expected test results with 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.

If you are having problems with your training, please review the Pega Academy Support FAQs.

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 Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice