Limitations for Case Type and Flow Unit Test Rules

When you create a Case Type or Flow Unit Test Rule it starts a record session for the given process. But I have run into the following issues:

  • When the Case Type or Flow requires some previously set data to perform correctly (A Child Case Type for example), if you start the recording, you don’t have that data. If a save the test case (to try and setup some data) I can’t continue my recording under the same Test Case Rule, hence my Test Case results in an incomplete process.
  • Let’s take a stand-alone Case Type that I was able to record. In my Unit Test Rule for that Case Type I want to be able to add some “Before rule execution” data under the Setup & Cleanup tab, but it seems the only data the Test Case uses is the “Test Data” generated in the UserInputs Data Transform.

Please advise on what is the best practice or best way to create Unit Test Rule for a Case Type or Flow Rule.

The limitation described at Best practices for designing Pega unit tests “Case type and flow Rules have limited support. Non-starter flows are not supported.” Means if it is a Child Case Type it is not supported?

Thanks in advance.

@SalvadorC94

To create a unit test rule for a Case Type or Flow Rule, ensure that all necessary data is set up using the “Setup & Cleanup” tab before starting the recording. Use data transforms or activities to prepare the environment. For Child Case Types, set up the parent Case Type and required data before recording. Follow best practices for designing Pega unit tests to handle dependencies and ensure a complete process.

:warning: This is a GenAI-powered tool. All generated answers require validation against the provided references.

Creating unit test Cases for processes and Case types

Data that you can record for flows and Case types

How to setup test data for Pegaunit tests

Unit testing individual Rules

Understanding unit test Cases

@MarijeSchillern

“To create a unit test rule for a Case Type or Flow Rule, ensure that all necessary data is set up using the “Setup & Cleanup” tab before starting the recording.”
This is the issue, this won’t work, because for creating a unit test rule for a Case Type or Flow Rule, you first do Actions > Run to start recording the process then you create the Unit Test Rule, you record before you can even use the Setup & Cleanup tab.

For example, you are recording a Flow or a Case Type but then you get stuck in the process because there is some data missing, you can’t resume the recording once you created the Unit Test Rule If you wanted to have previously set up some data.

“Use data transforms or activities to prepare the environment.”

Yes, this seems to be the only solution at the moment to ensure all necessary data is set up before the recording starts, this applies for setting up the data for Child Cases also, this approach implies building a data transform or activity and adding that to the Flow or Case Type in order to ensure that the Unit Test Rule Recording works properly.
This approach will make the automation to have a lot of complexity making this approach to not adhere to Pega Best Practices described at:
Best practices for designing Pega unit tests

Conclusion under my point of view: For Case Type and Flow Rules is better to create Unit Test Rules for starter Case Types and Flows only.