Back Forward How to unit test a Decision Table rule

About Decision Table rules

The Run Rule feature enables you to test a decision table rule individually before testing it in the context of the application 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, if Automated Testing is enabled, you can save the test data and its results as a test case rule.

Before you begin

Before you begin, determine how you will provide the sample data to use when testing the rule. Can you enter all the data in the Run Rule window? Or does the rule need specific pages to be on the clipboard to return a decision?

For general information about the Run Rule feature, including a list of the clipboard pages generated when a rule runs, see How to test a rule with the Run Rule feature.

Run the rule

To run the rule, complete the following steps:

  1. Save the rule.
  2. Complete any preprocessing necessary to create the appropriate clipboard context and, if the rule is circumstanced or time-qualified, to set the conditions you want to test.
  3. Click the Run button (Run). The Run Rule window appears.
  4. In the Test Page section, specify which page to use as the main page. Do one of the following:
    • select Create or Reset Test page. Then, in the Apply field, select the model to use for the test page.
      • In the lower section of the Run Rule window, enter the test data and click
         Run Again  . The system runs the decision table rule and displays the results.
    • If automated testing is enabled, select Auto-generate Test Cases. This will generate all test cases for this decision table. For more information, see the Pega Developer Network article PDNPRKB-25098 How to auto-generate test cases for a decision table.
    • If automated testing is enabled, select Run Against a Saved Test Case. Then choose an individual test case, all test cases, or all auto-generated test cases from the drop-down list.
      • If Automated Testing is enabled, you can click the
         Save as Test Case   button to create a test case rule that holds the test data and the results. For information about running test cases, see the Pega Developer Network document PDNPRKB-25096 How to create and execute test cases for decision tree and decision table rules.
  5. Optional. Click the Result Decision Paths link to go directly to the row on the Table tab that produced the test result. If the Evaluate All Rows option on the Results tab is selected, all the rows that are true are highlighted.
  6. Optional. Click  Show Clipboard   to open the Clipboard and examine the pages. Click  Hide Clipboard   to close the tool. For information about the clipboard pages that are generated, see How to test a rule with the Run Rule feature.
  7. Repeat as necessary, selecting other model rules or providing other input values.

Debugging decision table rules with the Tracer

If your decision table 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 decision tree rule as it occurs.

Complete the following steps:

  1. Select Run > Tracer.
  2. In the Tracer window, click the Options button (Options).
  3. In the Event Types to Trace section, select Decision Table.
  4. Select the RuleSet that contains the rule to be traced.
  5. Click  OK  .
  6. Return to the main portal and run the decision table rule.
  7. Watch the Tracer output as the rule runs.

zzzAbout Decision Table rules