Skip to main content

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

Performing unit testing on a When rule

Updated on May 31, 2022

For more efficient and detailed debugging, you can test a When rule individually before testing it in the context of the application that you develop. You can also convert the test into a Pega unit test case to validate application data by comparing the expected property values to the actual values that the test returns.

In a continuous delivery environment, Pega unit testing gives you feedback on the quality of your applications to ensure that you can quickly identify and correct issues.

By default, when you run the When rule, the result assertion uses the input value that you enter and the result that the test returns. The system generates the assertion when you convert this test to a test case.

  1. In the navigation pane of Dev Studio, click Records.
  2. Expand the Decision category, and then click When.
  3. In the list of When rule instances, click the rule that you want to test.
  4. In the rule form header, click ActionsRun.
  5. In the Run window, in the Run context pane, in the Thread list, select the thread in which you want to run the rule.
  6. In the Page list, select whether to copy parameter values from an existing page or to create an empty page:
    • To use parameter values from a clipboard page in the selected thread, click Copy existing page, and then, in the Page to copy field, select the page that you want to use.

      For example, you can select a clipboard page to test specific values.

    • To start a test from a page that contains no parameter values, click Empty test page.
    Note: The system runs the rule instance on the RunRecordPrimaryPage clipboard page, regardless of the page that you select from this list. If you convert this test run to a test case and the RunRecordPrimaryPage clipboard page requires initial values, configure the clipboard to populate the page with initial values. For more information, see Setting up your test environment.
  7. Optional: To apply a data transform to copy values for the test, select the Apply data transform checkbox, and then select the transform to apply.
  8. Optional: To change the values that the rule uses during the test, enter the new values on the main test page.
  9. Start the test by clicking Run.
  10. Optional: To convert the test run into a Pega unit test case, click Convert to test, and then configure the test case.
    For more information, see Creating unit test cases for rules.
  11. Optional: To view the pages that the unit test generates, click Clipboard.
What to do next: If the rule has errors, debug the rule by using the Tracer tool. For more information, see Debugging When rules with the Tracer tool.

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. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us