
Unit-Test-Regeln
4 Aufgaben
15 Min.
Szenario
Wenn ein Benutzer bei einem Case „Assistance Request“ wegen Pannenhilfe die Fahrzeugmarke eingibt, werden ein oder mehrere zugeordnete Modelle in der Dropdown-Liste „Model“ angezeigt. Gelegentlich melden Benutzer, dass beim Prozess „Submit Request“ bei der Eingabe der Fahrzeugdaten für bestimmte Automarken die Modellnamen in der Dropdown-Liste fehlen. Die Beteiligten müssen die Fahrzeugmarken schnell identifizieren können, ohne dass mindestens ein Modell zugeordnet ist.
Darüber hinaus machen sich die Beteiligten Sorgen wegen der Anwendungs-Performance. Um sicherzustellen, dass Kunden Anfragen wegen Pannenhilfe effizient abschließen können, wird vorgegeben, dass die Fahrzeugmodellliste innerhalb von 200 Millisekunden generiert werden soll.
In der folgenden Tabelle finden Sie die Anmeldedaten, die Sie zur Durchführung der Challenge benötigen.
Rolle | Benutzername | Kennwort |
---|---|---|
Application Developer | author@gogoroad | pega123! |
Challenge-Schritte
Genaue Übungsschritte
1 Run the List Vehicle models data page and test different Make values
- In the navigation pane of Dev Studio, click Data types to open the Data types explorer.
- Click Vehicle models, and then click List Vehicle models to edit the D_VehiclemodelsList data page.
- In the upper right, click Actions > Run. The Run Data Page window is displayed.
- In the Value field, enter Tesla as the test value.
- In the upper right, click Run. The pxResultCount returns a value of 1 record.
- In the Value field, enter Opel, and then click Run. The pxResultCount returns a value of 0 records, which confirms that not all vehicle makes have at least one associated model.
2 Create a unit test
- In the Run Data Page window, in the Value field, enter Tesla.
- In the upper right, click Run. The Convert to test button is displayed.
- Click Convert to test to close the Run Data Page window and create a test case record for the data page that uses the results of your test.
Hinweis: The parameter value entered in the Run Data Page window is automatically populated in the Test Case form.
- On the Test Case form, in the Expected results section, verify that the Assertion type drop-down value is Expected run time.
- In the Value field, enter 0.2 to set the passing threshold for the unit test to 0.2 seconds.
- In the second Assertion type 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 Tesla.
- Click Save.
- In the Label field, enter VehicleModelsList_Tesla to name the test case record.
- In the Add to ruleset and version lists, verify that the highest ruleset version is selected.
- Click Submit.
3 Create unit tests for different vehicle makes
- In the VehicleModelsList_Tesla test case, to the right of Save, click the down arrow.
- Click Save as.
- In the Label field, enter VehicleModelsList_Ford.
- Click Create and open 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 Ford.
- Click Submit to close the Edit details window.
- In the Description field, click the icon to edit the vehicle make.
- Following the text parameters, <Make: update Tesla with Ford.
- In the VehicleModelsList_Tesla test case, click Save.
- Repeat steps 1-10, using VehicleModelsList_Opel as the test case label and Opel as the Make parameter.
4 Confirm your work
- From the Configure menu, click Application > Quality > Automated testing > Unit testing > Test cases to display all the unit tests that you created for the GoGoRoad application.
- To the left of the Test case name column, select the check box to select all the test cases.
- Click Run selected to execute the unit tests.
- In the Result column verify that the Tesla and Ford unit test cases passed and the Opel unit test case failed.
- To the right of Failed, click View to see additional information and investigate why the Opel Test Case failed. The Test Runs Log dialog box is displayed.
- Click the test result. The test results for VehicleModelsList_Opel are displayed.
In der folgenden Mission verfügbar:
If you are having problems with your training, please review the Pega Academy Support FAQs.
Möchten Sie uns dabei helfen, diesen Inhalt zu verbessern?