Run PegaUnit's Rule Under Test on a different page than RunRecordPrimaryPage
In general, to create a pegaunit, when we run a rule from the Ruleform( Actions > Run ), these rules run on a particular page named as "RunRecordPrimaryPage". [ Some exceptions to this is Casetype rules and flow rules run on "pyWorkPage", Datapage is loaded on the same page etc].
So, when we run a pegaunit, we also run the RUT (Rule under test is the rule for which we are creating the unit test) on RunRecordPrimaryPage by default. Though this fits for many of the rules, but for a few cases, this was coming up as a limitation.
Say, if the RUT has some different page as a primary page? We know, If the RUT is run independently, it will run on RunRecordPrimaryPage, but if the RUT is executed during a scenario ( say during a case/flow execution), RUT will run on a different page( could be pyWorkPage itself or any other named page).
Many rules(data transforms, activities etc) refers TOP keyword, to refer the TOP level page. During case/flow execution this can refer to any named page in the Thread.
We will take a banking application example. Say, a user is looking for credit card benefits for different types of Credit card category.
After the user selects a particular plan, the Benefits attached to this will be populated and shown to the user in the next screen.
There is a Data transform, which is populating the data in the background.
As, we can see, this DataTransform reads "SelectedPlan" property from the top-level page. And after that it populates the "Benefit" for that plan.
This Datatransform is our RUT, and we will try to create a testcase for it. During the case execution, the "SelectedPlan" property will be present in pyWorkPage. So, if we copy pyWorkPage to the testcase as setup, after the RUT data transform execution, it will populate the benefit. We need not create any other set up for that.
Now that we have the available data, we can run the RUT. But, out RUT(data transform) refers to "TOP" to locate the primary page. And we know, to run the RUT, we use RunRecordPrimaryPage. And, there was no such option till 8.3, to use this same copied page as the primary page to run the RUT. So, though users were able to capture set up data from case thread, this was putting a restriction to the test writer.
(only workaround to tackle this problem was, Testwriters needed to copy this page again to RunRecordPrimaryPage so that RUT would be running with correct data.)
To, help test writer, from 8.4 onwards, we have given support to run pegaunits on a named page.
In the "Setup & Cleanup" tab, we have introduced an advanced section. In that user can mention a PageName. we will make sure, RUT run on that page itself.
If user keeps this field empty, default "RunRecordPrimaryPage" will be used to run the RUT.
So, with this option, all those rules can be automated using pega units which ran on different page (than RunRecordPrimaryPage)