Performing Pega unit testing
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:
- Create Pega unit tests for the data page with different values for the Make list.
- Run the created unit tests.
- Open any failed test case, and then identify the reason for failure.
The following table provides the credentials you need to complete the challenge.
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.
1 Run the Vehicle List data page and test with different Make values
- Log in to the Dev Studio as the Application Developer with User name pgpTester and Password rules123!
- In the navigation pane of Dev Studio, click App to open the App Explorer.
- In the App Explorer, in the search field, enter PegaPS-Data-Entity-Vehicle.
- On the Classes tab, expand and then click to open the data page.
- In the upper-right corner of the D_Vehicle list data page, click Actions > Run to open the Run Data Page window.
- In the Run Data Page window, for the Make parameter, in the Value field, enter Honda as the test value.
- Leave the other parameters empty.
- In the upper right, click Run to test the data page.
- Expand the pxResults property.
- Confirm that the property includes only one result page.
2 Create a Pega unit test case for a data page
- In the upper right, click to open the Pega unit rule in a new tab.
- Close the Run Data Page window. Note: The parameter values that you enter in the Run Data Page window are automatically populated on the Test Case form.
- On the Test Case form, in the Expected results section, verify that the list value is Expected run time.
- In the Value field, enter 0.2 to set the passing threshold for the unit test.
- In the second list, select Result count.
- In the of object field, enter or select .pxResults.
- In the Comparator list, select is greater than.
- In the Value field, enter 0.
The unit test validates that at least 1 record is returned from the data page when the Make parameter value is Honda.
- Click .
- In the Label field, enter TC_VehiclesList_Honda to name the test case record.
- In the Add to ruleset and version lists, verify that the highest ruleset version is selected.
- Click .
3 Create Pega unit test cases for different vehicle makes
- After saving the TC_VehiclesList_Honda test case, to the right of the
, click the .
- Click .
- In the Label field, enter TC_VehiclesList_Hyundai.
- Click to save a copy of the test case.
- To the right of Class, click the Gear icon to open the Edit details window and update the rule parameters.
- In the Parameter(s) sent section, in the Make field, enter Hyundai.
- Click Edit details window. to close the
- In the Description section, click the Edit icon to edit the vehicle make.
- In the text parameter, in the <Make: Hyundai> string, replace Honda with Hyundai.
- Click to complete the configuration of the unit test.
- Repeat steps 1-10, using TC_VehicleModelsList_tvs as the test case label and Saturn as the Make parameter.
Now, you have created three test cases with different makes of vehicles.
Confirm your work
- 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.
- In the Test case name column, select the Test case name checkbox to select all test cases.
- Click to execute the unit tests.
- In the Result column, verify that the Honda and Hyundai unit test cases have passed, and the TVS unit test case has failed.
- To the right, click Test Runs Log dialog box and to investigate why the TVS test case failed. for additional information in the
- Click the test result to view the test results for TC_VehiclesList_tvs.
Unit testing is performed on all the supported rules in this application.