Back Forward How to unit test a flow rule

About Flow rules

Typically, you test a flow rule individually before testing it in the context of the entire application that you are developing. You run through the flow, providing sample data as the input, and examine the behavior and results to see if they are what you expect.Proj-94 C-2409 C-1493

If you have the AutomatedTesting privilege through an access role, you can use the options in the Test Cases tab in the flow rule form to run your flow with the option to record and save test cases.

The steps here for unit testing flows are applicable only to starting flows — that is, flows that have the Creates a new work object option selected on their Process tabs. To unit test subflows and screen flows, you run the main flow that calls them.

For general information about testing a rule using the Run button Run, including a list of the clipboard pages that are generated when a rule runs, see How to test a rule with the Run Rule feature.

When you are testing a flow rule, the system creates a new test page and starts executing the flow, and you can create a work object. The type of window, the portal, and the skin rule (styles and appearance) of the work object form depend on the Run Process In settings in the General group of your operator preferences. See Designer Studio — Setting your preferences.

Starting the unit test

To start the run of the unit test:

  1. Save the rule.
  2. From the flow rule form, start the run of the flow:
    • If you do not have the AutomatedTesting privilege, click the Run button Run.
    • If you have the AutomatedTesting privilege, on the Test Cases tab of the flow rule form, click Record New Test Case.

    The system creates a new test page, and then starts a flow rule execution and you can create a work object.

  3. Step through each decision or assignment, providing representative input in each step.

    If you have the AutomatedTesting privilege, after the work object is created and you are running through the flow, the following options are available:

    Field

    Description

    Save Test Case

    Click to create a test case rule that holds the test data and the results for the flow execution recorded up to the point at which you click this button. The recording stops, the New Instance window for the new test case rule opens, and you can specify a name and description for the test case.

    For information about flow test cases, see the articles in the Testing Applications category of the Pega Developer Network.

    Save Flow Marker

    Click to create a flow marker at a point in the flow. Flow markers identify points in the flow that you can jump to without having to input the same information again to reach that point. The recording stops and the New Instance window for the new flow marker rule opens; specify a name and description for the flow marker.

    For information about flow markers, see the articles in the Testing Applications category of the Pega Developer Network.

    Save Resume Test Case

    Click to create a resume test case rule that holds the test data and the results for the flow process recorded between the previous assignment in the flow and the current assignment at which you click this button. The recording stops, the New Instance window for the new test case rule opens, and you can specify a name and description for the resume test case.

    Stop Recording

    Resume Recording

    Use these buttons to toggle between stopping and resuming the recording of the flow execution.

    After the work object is created, recording is in progress. If the recording is stopped, either from saving a test case at a point in the flow or from clicking the Stop Recording button, click the Resume Recording to begin recording again.

    Cancel

    Click to cancel the flow execution. The system returns to the start of the flow before creation of the work object.

  4. Run through the rule as many times as necessary, testing each possible path. Use the Where-Am-I? arrow Where am I?to see where an assignment is located in the flow rule diagram.

Related PDN articles

Up About Flow rules