Skip to main content

Creating unit test Cases

Note: This content describes procedures not covered in the module challenge. Your certification exam may include questions on these tasks.

Creating unit test Cases for Rules

Pega Community logo

Note: The following content, referenced from Pega Documentation, is included here to help you better achieve the module learning objectives.

For most Rules, you can create a reusable test Case by converting a unit test to a test Case, configuring Case details, and then defining expected test results with assertions (test Conditions). When the test Case runs, the test results are compared to the expected results defined for the Rule’s assertions. If the test results do not meet the defined assertions, then the test fails.

Before you begin:

Unit test a rule and convert the test run into a test Case. For more information, see Unit testing individual Rules.

  1. Optional: To modify the rule or class that is used for the test, in the upper-right corner of the Definition tab, click the Gear icon, select the rule or class and then click Submit.

    If you are testing a strategy rule, then the componentName and pzRandomSeed parameters are also displayed. If you change either of these parameters, the test Case does not return the expected results.

    • componentName – The name of the component (for example, Switch) that you are testing.
    • pzRandomSeed – An internal parameter, which is the random seed for the Split and Champion Challenger shapes.
  2. Optional: To prevent the test from being run as part of a test suite or from a REST service, on the Definition tab, select the Disable check box.
    The test Case will be run only when you click Actions > Run.
  3. In the Expected results section, add assertions that define the expected results of the test. For more information about creating assertions, see Assertions.
  4. On the Setup & Cleanup tab, configure the Actions to perform and the objects and Clipboard Pages to be available before and after the test runs. You can also clean up the Clipboard after the test is run by applying additional Data Transforms or activities. For more information, see Setting up your test environment.
  5. Click Save.
  6. In the Details dialog box, enter a label that identifies the test Case. The test Case identifier is generated based on the label and cannot be modified after it is saved.

Creating unit test Cases for Processes and Case Types

Pega Community logo

Note: The following content, referenced from Pega Documentation, is included here to help you better achieve the module learning objectives.

When you create a unit test Case for a process or Case Type, you run the process 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.

Certain Conditions apply on the data that you can record for processes and Case Types. For information, see Data that you can record for flows and Case types about the data that you can record.
RESTRICTION: From Pega Platform™ version 8.5, running and recording a test Case for a process that has a Create Stage is no longer possible for new Case Types. If you have migrated from a version lower than 8.5, you can include the process in any Stage of a migrated Case Type, and then run the test on the process.

Before you begin:

Exclude properties in your work class from the test by modifying the pxCapturePropertyIgnore Data Transform. For more information, see Data that you can record for flows and Case typesabout the data that you can record.

  1. Open the flow or case type for which you want to record a test.
  2. On the toolbar, click Actions > Record test Case.
    The system starts running the flow or Case Type.
  3. Enter input as you step through the flow or Case Type.
  4. Click Create test Case in the lower-right of the screen to save the recording as a test Case.
  5. Click Save, enter a label that identifies the test case, and then click Submit.
  6. Optional: To modify the rule or class that is used for the test, in the upper-right corner of the Definition tab, click the Gear icon, select the rule or class, and then click Submit.
  7. Optional: To prevent the test from being run as a part of a test suite or from a REST service, on the Definition tab, select the Disable check box.
    The test Case will be run only when you manually click Actions > Run.
  8. In the Expected results section, add assertions that define the expected results of the test. For more information about creating assertions, see Defining expected test results with assertions.
  9. On the Setup & Cleanup tab, configure the Actions to perform and the objects and Clipboard Pages to be available before and after the test runs. You can also clean up the Clipboard after the test is run by applying additional Data Transforms or activities. For more information, see Setting up and cleaning the context for a test Case or test suite.
  10. Click Save.
  11. Configure the unit test Case.

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.


This Topic is available in the following Module:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice