Performing unit testing on a When rule
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.
- In the navigation pane of Dev Studio, click Records.
- Expand the Decision category, and then click When.
- In the list of When rule instances, click the rule that you want to test.
- In the rule form header, click .
- In the Run window, in the Run context pane, in the Thread list, select the thread in which you want to run the rule.
- 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.
- 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.
- 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.
- Optional: To change the values that the rule uses during the test, enter the new values on the main test page.
- Start the test by clicking Run.
- 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.
- Optional: To view the pages that the unit test generates, click
Clipboard.For more information, see Clipboard pages created by the Run Rule feature.
Previous topic More about When Condition rules Next topic Debugging When rules with the Tracer tool