Creating a Pega unit test case for a flow or case type

When you create a Pega unit test case for a flow or case type, you run the flow or case type and enter data for assignments and decisions. The system records the data that you enter in a data transform, which is created after you save the test form. You can start recording at any time.

For information about the data that you can record, see Data that you can record for flows and case types.

Some properties, like .pyID, are not processed when a Pega unit test case is run. These properties vary for every test run. The pxDataCapturePropertyIgnore data transform displays the properties that Pega unit tests do not process.

  1. Exclude properties in your work class from the test by modifying the pyDataCapturePropertyIgnores data transform.

    Complete the following steps:

    1. Click App > Classes.
    2. In the search field, enter Work-.
    3. Expand Data Model > Data Transform.
    4. Click the pyDataCapturePropertyIgnores data transform.
    5. Save the data transform to your Work- class and in your test ruleset.
    6. On the Definition tab, click the plus sign.
    7. From the Action list, select Set.
    8. In the Target field, enter the property that you want to exclude.
    9. In the Source field, enter two double quotation marks, separated by a space " ".
    10. To specify additional properties that you want to exclude, repeat step f through step i.
    11. Save the data transform.
  2. Complete one of the following tasks:
    • Open a flow by searching for it or by using the Application Explorer.
    • Open a case type by clicking Cases and then clicking the case type that you want to open.
  3. From the toolbar, click Action > Record test case. The system starts running the flow or case type.
  4. Enter input as you step through the flow or case type.
  5. Click Create test case in the bottom right corner of the browser to start recording the test case and create a test case in a new tab. The test case contains all the information that you entered up until you created the test case.

    You can continue to run the flow or case type and create additional test cases in the tab that is running the flow or case type.

  6. Configure the Pega unit test case. See Modifying Pega unit test cases for more information.
Result: 

After you save the test case, a data transform, which captures the input that you entered, is created and associated with the test case. You can edit this data transform to modify the test case input. The Edit test case form also displays the path of the flow or case type.