Close popover
Goutam Saha (sahag)
 Principal  Cloud Development Engineer
Pegasystems Inc.
sahag Member since 2015 4 posts
Posted: October 8, 2020
Last activity: October 8, 2020

Mocking a datapge for PegaUnit test

Datapage’s data loading strategy can make calls to external systems by using connectors / can load data from database / can do some complex tasks in an activity and at the end load data. If our tested rule(RUT or Rule Under Test) is using a data page,  for testing perspective, this external calls /  complex activity call can be avoided,  as the external server may not be available, or complex activity calls may require additional setup. if we can populate this datapage with desired set of values, then the purpose would be solved.

Datapage mocking can be used to achieve this. We can use the “Simulation” block in “Setup & Cleanup” tab, and add a new simulation rule. Datapages directly referenced in the RUT will be auto populated but user can mock other data pages also.


Let us take an example to understand the scenario and how to use mocking which can make our lives easy to test the rules where Datapages are used.

Our Rule under Test is an activity “GetFullTimeEmployees”, is using a Datapage (D_pzEmployeeList) and loading a list of employees, and then depending on the parameter “Role”, its filtering and copying the employee to EmployeeList created in step 1.





Now, while testing this activity, if we can populate this datapage with required data, the loading strategy need not run ( Strategy defined in the data page rule loads a huge chunk of data from the database).

We have added this Datapage in the Simulation section and chosen 'Select datatransform rule' (Simulation Strategy).



And using this data transform(CreateEmployeeMock) we are loading a smaller set of data required for testing.



Now, during testcase, instead of calling the loading strategy mentioned in the Datpage rule, this data transform will be used to load the data in the data page.

And, in this way, we can simply mock the data page, and get rid of any complex setup / making calls to external system.

There are 2 other strategies, for the same purpose, and user can use them as per requirement.

  1. 'Define data here' – The data can be populated inline, using the model. And same will be populated in the datapage at runtime.  
  2. 'As defined in the rule' – Datapage ruleform also gives an option to declare a rule which will be used instead of the actual data-population strategy. If this option is selected  as the simulation strategy, then Pegaunit makes sure that rule (defined in the datapage rule itself) is invoked at run time.    If user has selected this option, but did not mention any simulation strategy(in the datapage rule), then the normal flow will happen and data page will be loaded with the actual loading strategy.


    As per the current implementation, all thread level data pages can only be mocked.

Pega Automated Unit Testing DevOps Developer Knowledge Share