Skip to main content


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

Unit testing a decision tree

Updated on November 15, 2021

You can use the Run Rule feature to test a decision tree individually before testing it in the context of the application that you are developing.

You specify a test page for the rule to use, provide sample data as the input, run the rule, and examine the results. Additionally, you can convert the test run to a Pega unit test case.

  1. In the navigation pane of Dev Studio, click RecordsDecisionDecision Tree, and then select the decision tree you want to test.
  2. Click ActionsRun.
  3. In the Data Context list, click the thread in which you want to run the rule.
  4. Select a method for creating the test page.
    • Select Copy existing page to copy values from a thread of an existing clipboard page to the main test page.
    • Select Create or reset test page to create a new test page or reset the values of an existing test page.
      • To apply a data transform to the values on the test page, click the link in the Apply field and then select a data transform.
      • To clear the Result pane, click Reset Page.
      • To switch the current context, select a thread in the Data Context list and then click Switch Context.
  5. To display the test results, enter data in the Result panel and then click Run again.
    Result: The value that you enter and the result that is returned are the values that are used for the default decision result assertion that is generated when you convert this test to a test case.
  6. Optional: To view the pages that are generated by the unit test, click Show Clipboard. For more information, see Clipboard pages created by the Run Rule feature.
  7. To convert the test into a Pega unit test case, click Convert to Test. For more information, see Creating unit test cases for rules.
  8. Optional: To view the row on the Decision tab that produced the test result, click the Result Decision Paths link.
  • Debugging decision trees with the Tracer

    If your decision tree 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 decision tree 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