Skip to main content

Performing Pega unit testing

3 Tasks

15 mins

Pega Platform 8.7
Visible to: All users
Beginner Pega Platform 8.7 DevOps English


For an Assistance Request case, when users enter the make of a vehicle, one or more associated vehicles are displayed in the Vehicle list. Users report that when they enter the vehicle information during the Submit request process, some vehicle makes do not display an associated vehicle in the list. Stakeholders want to ensure that at least one vehicle is related to the value of the Make field. 

In addition, stakeholders are concerned about application performance. To ensure customers can complete Assistance Request cases efficiently, stakeholders want the vehicle list to generate within 200 milliseconds.

As the application developer, ensure that the data page returns the Vehicle list and determine whether the list is generated within the expected time interval. 

The data page displays the list of vehicles based on details such as Make and Model.

As an application developer, you need to unit test the developed features:

  1.  Create Pega unit tests for the data page with different values for the Make list.
  2.  Run the created unit tests.
  3.  Open any failed test case, and then identify the reason for failure.

The following table provides the credentials you need to complete the challenge.

Role User name Password
Application Developer pgpTester rules123!
Note: Your practice environment may support the completion of multiple challenges. As a result, the configuration shown in the challenge walkthrough may not match your environment exactly.

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Detailed Tasks

1 Run the Vehicle List data page and test with different Make values

  1. Log in to the Dev Studio as the Application Developer with User name pgpTester and Password rules123!
  2. In the navigation pane of Dev Studio, click App to open the App Explorer.
  3. In the App Explorer, in the search field, enter PegaPS-Data-Entity-Vehicle.
  4. On the Classes tab, expand Data Model and then click D_VehicleList to open the data page.
  5. In the upper-right corner of the D_Vehicle list data page, click Actions > Run to open the Run Data Page window.
  6. In the Run Data Page window, for the Make parameter, in the Value field, enter Honda as the test value. 
  7. Leave the other parameters empty.
  8. In the upper right, click Run to test the data page.
  9. Expand the pxResults property.
  10. Confirm that the property includes only one result page. 
    Image depicts the the pxResults property on which the property includes the results pages.

2 Create a Pega unit test case for a data page

  1. In the upper right, click Convert to test to open the Pega unit rule in a new tab.
  2. Close the Run Data Page window.               Image depicts the Convert to test button
    Note: The parameter values that you enter in the Run Data Page window are automatically populated on the Test Case form.
    Image depicts the Make field is set to Honda
  3. On the Test Case form, in the Expected results section, verify that the Assertion type list value is Expected run time.
  4. In the Value field, enter 0.2 to set the passing threshold for the unit test.
    Unit test expected run time 0.2 seconds
  5. In the second Assertion type list, select Result count
  6. In the of object field, enter or select .pxResults.
  7. In the Comparator list, select is greater than.
  8. In the Value field, enter 0.
    Assertion type
    The unit test validates that at least 1 record is returned from the data page when the Make parameter value is Honda.
  9. Click Save.
  10. In the Label field, enter TC_VehiclesList_Honda to name the test case record.
  11. In the Add to ruleset and version lists, verify that the highest ruleset version is selected.
    Saving test case with appropriate name
  12. Click Submit.

3 Create Pega unit test cases for different vehicle makes

  1. After saving the TC_VehiclesList_Honda test case, to the right of the Save, click the down arrow.
    Image depicts the drop down arrow button next to the Save button
  2. Click Save as.
  3. In the Label field, enter TC_VehiclesList_Hyundai.
  4. Click Create and open to save a copy of the test case.
  5. To the right of Class, click the Gear icon to open the Edit details window and update the rule parameters.
    Image depicts the Gear icon to edit the parameter of the test case
  6. In the Parameter(s) sent section, in the Make field, enter Hyundai
    Image depicts the Edits made to the Make field of a test case
  7. Click Submit to close the Edit details window.
  8. In the Description section, click the Edit icon to edit the vehicle make.
    Image depicts the edit of the description field of a test case
  9. In the text parameter, in the <Make: Hyundai> string, replace Honda with Hyundai.
  10. Click Save to complete the configuration of the unit test.
  11. Repeat steps 1-10, using TC_VehicleModelsList_tvs as the test case label and Saturn as the Make parameter.
    test case with make as tvs

Now, you have created three test cases with different makes of vehicles.

Confirm your work

  1. In the header of Dev Studio, click Configure > Application > Quality > Automated testing > Unit testing > Test cases to display all the unit tests that you created for the application.
  2. In the Test case name column, select the Test case name checkbox to select all test cases.
  3. Click Run selected to execute the unit tests.
    Image depicts the Pega unit tests landing page
  4. In the Result column, verify that the Honda and Hyundai unit test cases have passed, and the TVS unit test case has failed.
    Results of test cases on the landing page after execution
  5. To the right, click View for additional information in the Test Runs Log dialog box and to investigate why the TVS test case failed.
  6. Click the test result to view the test results for TC_VehiclesList_tvs.
    Image depicts the failure result of a test case.
    Unit testing is performed on all the supported rules in this application.

Available in the following mission:

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