Unit Testing Multi Level Strategies

We are using Pega 8.4 version and exploring the capabilities with the NBAD approach as recommended. I can see the framework level strategies are generated for me with some extension points to cater to any specific requirements.

My question is how to unit test the extension strategy which is dependent on the result from its parent strategies.

For instance, if my Action is getting dropped at TreatmentsChannels strategy and need to investigate why so.

The top level strategy can be unit tested for each of the components.

How do we unit test the strategy which is next in the hierarchy?

One way I can do is by checking out this strategy and copying all the first 4 components from parent strategy and getting rid of external input. But this is not a good option at all, as we keep checking out the strategies that are generated by the system.

This is just a strategy at level 3, consider some of the strategies that are at much deeper in hierarchy for example:

If we need to add our specific requirements to extension strategy ContactPolicyExtension, how do we unit test it? Below is the level of the extension point strategy

Trigger_NBA_TopLevel
NBAStrategyFramework
TreatmentsChannels
OutboundChannels
OutboundLimits
ContactPolicyExtension

Any insight on this is appreciated.

We will soon be publishing a component article on how to test the Next-Best-Action strategy framework but here are the abbreviated steps you can follow.

NBAStrategyFramework

If you see that strategy results are getting dropped from the NBAStrategyFramework component in the trigger_ strategy, the next step is to debug the NBAStrategyFramework strategy to see at which high level component results are dropping out.

Testing the NBAStrategyFramework and lower strategies requires that you add an external input strategy which will provide the actions you want to test against.

NBAStrategyFramework strategy – Testing the non-generated components of the strategy framework.

  1. Open the NBAStrategyFramework strategy
  2. Open the Test Run panel by clicking of the slider button
  3. Select the CustomerPersona or other persona transform based on your Context Dictionary configuration and click the Open icon.
  4. On the Definition tab of the data transform, specify the characteristics of the persona.

The persona characteristics are defined as properties of the customer, their journey, and other related data. For example, if you have a specific test customer contact that you want to use as a test persona, enter their ID in the Set .ContactId equal to row. You can add new properties by right-clicking on a row and selecting Add child.

  1. Save the data transform and switch back to your trigger strategy.
  2. Select or Create an external input strategy. Create a strategy called ExternalInputTester and click the Open icon.
  3. Select your primary decision context, this will typically be called Customer and make sure there is No development branch selected. Create and Open the strategy
  4. Inside the Customer context box, add a Proposition Import shape and select the Issue, Group, Action you want to test.
  5. Save and Checkin the ExternalInputTester strategy
  6. Click the Run button and then select the Result component to view the final strategy results (SR).

Debugging Lower strategies

You follow these same steps for debugging strategies that are lower in the strategy stack but depending on the strategy you are debugging, you’ll need to update the ExternalInputTester strategy to ensure your strategy results include any required component logic.

Let’s say you want to debug strategy results that are dropping out on the Treatments & Channels component of the NBAStrategyFramework strategy.

  1. From the NBAStrategyFramework strategy, open the TreatmentsChannels strategy.
  2. Open the Test Run panel by clicking of the slider button
  3. Select the CustomerPersona or other persona transform based on your Context Dictionary configuration and click the Open icon.
  4. On the Definition tab of the data transform, specify the characteristics of the persona.

The persona characteristics are defined as properties of the customer, their journey, and other related data. For example, if you have a specific test customer contact that you want to use as a test persona, enter their ID in the Set .ContactId equal to row. You can add new properties by right-clicking on a row and selecting Add child.

  1. Save the data transform and switch back to your trigger strategy.
  2. Select the ExternalInputTester external input strategy and click the Open icon.
  3. Add the Required strategy component for action scoring, ActionLevelPropensity. This component will expand the action by the number of active and enabled channels which is needed to debug our treatment strategy.
  4. Save the ExternalInputTester strategy and switch back to the TreatmentsChannels strategy
  5. Click the Run button and then select the Result component to view the final strategy results (SR).

TreatmentsChannels strategy: This strategy will test joining actions with active treatments as well as run the Prediction to determine the treatment level propensity.

ExternalInputTester strategy: This strategy imports the actions you want to test as well as any required logic components. As you test component lower than the NBAStrategyFramework, include the high level components in this strategy.

I hope this helps