Run API tests in a GUI test - Use-case scenario
Relevant for: GUI tests only
This use-case scenario describes an example of how to incorporate tests for the API (service) layer of your application into a GUI test.
For the purposes of this scenario, you will be using a flight booking application similar to the Flight GUI and Flight API applications provided with the UFT One installation and used in the GUI tutorial for Web applications.
In your application, you have four different pages, which correspond to the different tasks involved in booking a flight:
|Logging in to the booking site||Login page|
|Finding flight options based on customer selections||Flight Finder page|
|Selecting a flight from the list of flight options||Select Flight page|
|Booking and confirming a customer's flight selection||Book Flight page|
In addition, your application has a number of API processes to help the application process flight booking requests:
|Finding user login credentials in the database||Login operation|
|Searching for a list of all available flights and displaying the flight list||FindFlights operation|
|Creating a flight order||CreateFlight operation|
|Confirming a flight booking||ConfirmBookFlight operation|
|Updating a flight order||UpdateFlightOrder operation|
|Deleting a flight order||DeleteFlightOrder operation|
|Deleting all flight orders||DeleteAllFlightOrders operation|
Create your test
You do the following:
Create a separate GUI action for each application page, giving it the same name as the page name.
Create a separate test for each API process, naming each test with the process name.
In order to fully test your application, you decide to place an API test after each GUI test. The API test checks to see whether the API processes run by that specific application's page (Login, Flight Finder, Select Flight, or Book Flight) are working correctly.
In your GUI actions, you insert a call to the corresponding API test.
The API test appears is displayed as nested inside the GUI action.
After you insert all the calls to the corresponding API tests, you have a call to an API test inside each of your GUI test actions as listed in the table below:
GUI Test Action Name
Login Page Login Flight Finder Page FindFlights Select Flight Page CreateFlight Book Flight Page ConfirmBookFlig
Note: If you want to pass data from a API test to use in an GUI test, you must create a test output parameter in your API test.
Run the test
After adding the necessary calls to your API tests, you can run the test.
The GUI test executes each step the user interface in the flight booking application user interface.
For each API test call in the GUI test, UFT One compiles the API test and runs it. UFT One displays the API test steps running in the Output pane.
After the test run is complete, you can check the test results for the GUI test, including calls to each of the API tests. The run results show the completion and pass/fail status for each step.