Skip to main content


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

Unit testing a when rule

Updated on November 15, 2021

You can test a when rule individually before testing it in the context of the application that you are developing. Additionally, you can convert the test into a Pega unit test case to validate application data by comparing expected property values to the actual values that are returned by the test.

In a continuous delivery environment, Pega unit testing provides you with feedback on the quality of your applications, so that you can quickly identify issues and correct them.

By default, when you run the when rule, the result assertion uses the input value that you enter and the result that is returned. The assertion is generated when you convert this test to a test case.

  1. In the navigation pane of Dev Studio, click RecordsDecisionWhen, and then select the when rule that you want to test.
  2. Click ActionsRun.
  3. In the Run context pane, select the thread, test page, and data transform you want to use for the test.
    1. In the Thread list, select the thread in which you want to run the rule.
    2. 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 an existing clipboard page in the selected thread, click Copy existing page, and then select the page you want to copy.

      • To start from a page containing no parameter values, click Empty test page.

    3. Optional: To apply a data transform, select the Apply data transform check box, and then select the transform to apply.
      Note: The system always runs the rule instance on the RunRecordPrimaryPage, regardless of the page that you select from this list. If you convert this test run to a test case and the RunRecordPrimaryPage requires initial values, then configure the clipboard so that it populates the page with initial values. For more information, see Setting up your test environment.
  4. Optional: To change the values that are passed to the rule, provide the new values on the main test page.
  5. Click Run to run the test.
  6. 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.
  7. To view the pages that are generated by the unit test, click Clipboard. For more information, see Clipboard pages created by the Run Rule feature.
  8. If the rule has errors, then debug it using the Tracer tool. For more information, see Application debugging using the Tracer tool.
  • Debugging when rules with the Tracer

    If your when rule does not give you the results you expect and you cannot determine the problem by running the rule and examining the clipboard pages, run the Tracer tool. With the Tracer, you can watch each step in the evaluation of a when rule as it occurs.

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