Back Forward How to Unit Test a Decision Table Rule

About Decision Table rules

Proj-94 C-2409 C-1493The Run Rule feature enables you to test a decision table rule individually before testing it in the context of the application you are developing. B-17319 circumstance NORIR You specify a test page for the rule to use, provide sample data as the input, run the rule, and examine the results.

If you have the AutomatedTesting privilege (through an access role), you can use the features of Automated Unit Testing such as saved test cases and unit test suites for testing your decision table rule. See About Automated Unit Testing and Working with the Test Cases tab for more information.

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: select Create or Reset Test page and in the Apply field, select the model to use for the test page or leave the default. Click Reset Page to clear any prior test data from the Results section of the window. B-20360 REJECTED

    If you have the AutomatedTesting privilege, the Auto-generate Test Cases and Run Against a Saved Test Case choices are available:

    • To have the system generate all test cases for this decision table by iterating through the conditions in the table, select Auto-generate Test Cases and click the Generate Test Cases button. For more information, see the articles in the Testing Applications category of the Pega Developer Network.
    • If saved test cases exist for this rule, you can run the rule and see how its behavior compares to that in the saved test cases by selecting a choice for the Run Against a Saved Test Case field. You can choose to unit test against a specific test case, all test cases, or all auto-generated test cases.

      After making your selection, click Run Test Case. If differences are found between results of running the current state of the rule and the saved test case, they are displayed and you have the options of overwriting the saved test case, viewing the rule history, and saving the results.

  5. If you are not auto-generating test cases or running against a saved test case, specify the test data in the lower section of the Run Rule window, and click  Run Again . The system runs the decision table rule and displays the results.

    If you have the AutomatedTesting privilege and you want to save this run as a test case, click Save Test Case.

  6. 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. C-1637 NORIR
  7. Optional. Click  Show Clipboard   to open the Clipboard and examine the pages. Click  Hide Clipboard   to close the tool. B-20333B-20454 rejected not refreshed For information about the clipboard pages that are generated, see How to test a rule with the Run Rule feature.
  8. Repeat as necessary, selecting other model rules or providing other input values.

Debugging decision table rules with the Tracer

C-446 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 table rule as it occurs.

Complete the following steps:

  1. Click the Tracer icon in the Quick Launch area to start the Tracer. BYRNB 2/22/10
  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. (Clear the other RuleSets to avoid memory usage from tracing events occurring in other RuleSets.)
  5. Click  OK  .
  6. Return to the main portal and run the decision table rule.
  7. Watch the Tracer output as the rule runs.

UpAbout Decision Table rules