Skip to main content

Configuring test data for Pega unit test cases

Every rule requires input data to execute the logic defined in the rule, and depending on the logic, the rule produces output data. The input data that is required by the rule must be configured as part of the test case itself to keep the test case independently executable on any environment irrespective of the data available in that environment. This makes it easy for users to debug and maintain the test cases during test case failures and refactoring.

You can configure the test data for a rule using the Setup & Cleanup tab of the Pega unit test case rule form as shown in the following image.

Setup and cleanup

You can perform following tasks from the Setup section of Setup & Cleanup tab of the Pega unit test case, to configure and manage test data.

  • Create test data before a rule runs, so that the data is available for the rule as input.
  • Simulate the output of certain rules that are not available, so that the calls to these rules can be bypassed and pre-defined data can be supplied instead.
  • Arrange data for validations after a rule runs.

Configuring test data before the rule runs

You must configure steps to create test data on the clipboard and make that data available for the rule before the rule runs as part of the test case. The steps that you configure, run first when you initiate the test case created on the clipboard. The rule accesses the data according to the rule logic.

You can create or copy clipboard pages from the Setup data section of Before rule execution. For more information about creating and copying pages, refer to Copying and creating clipboard pages in setup 

Note: The pages that you copy or create are loaded to the clipboard each time the test case runs, and the data is set on the clipboard for the rule to access. 

Apart from creating and copying clipboard pages, you can also configure additional data on the clipboard from the Additional clipboard data section of Before rule execution through the following actions.

  • Apply data transform
  • Execute activity
  • Load data page
  • Load object
  • Create data object
  • Create work object

For more information about configuring additional data on the clipboard before a rule runs, refer to Adding additional clipboard data.

Simulating rules

From the Simulation section, you can simulate rules for which the test case is created, in case you want to test the outcome of those rules. This approach helps you verify the outcome when the rules in the test case are not ready or when they involve integrations that are not necessary to test a rule in isolation. 

Note: Currently, the simulation feature is available only for the Data page and Connect rules. You can simulate calls to these rule types by providing hard-coded data as the expected output from these rules.

For more information about how to configure simulations for rules, see Simulating data pages.

Arranging data after the rule runs

You can configure actions to run after the rule is executed to order the output data or load pages that are removed by the rule as part of the logic, so that the validations can happen correctly. 

You can configure the following actions from the After rule execution section to arrange test data after a rule runs:

  • Apply data transform
  • Execute activity
  • Load data page
  • Load object
Note: These actions can be configured in a similar manner as done in the Add additional clipboard data in the Before rule execution feature. For more information about configuring the test data on the clipboard after a rule runs, refer to Adding additional clipboard data.

Check your knowledge with the following interaction.


This Topic is available in the following Module:

If you are having problems with your training, please review the Pega Academy Support FAQs.

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 Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice