Unit testing a when rule
You can test a when rule individually before testing it in the context of the application that you are developing. To test a when rule, use the Run Rule feature. Optionally, you can convert the run 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.
- Click and select the when rule that you want to open.
- Click Actions > Run.
- In the Thread list in the Run context pane, select the thread in which you want to run the rule.
-
Specify initial setup values for the clipboard.
- Optional: On the main test page, enter the values for parameters to pass to the rule.
- Click Run to display the result that is returned by the test.
- Optional:
Convert this test into a Pega unit test case.
- Click Convert to test. A new tab is displayed in the main Dev Studio window.
- Configure the Pega unit test case. For more information, see Configuring Pega unit test cases.
- Optional: Click Clipboard to open the Clipboard and review the pages that are generated by the unit test.
- Optional: If the rule has errors, click Trace to debug the rule with the Tracer tool.