Create an API test - Use-case scenario

Relevant for: API testing only

Creating a test is comprised of several stages. This section walks you through the stages you might perform when preparing a test for the Flight API application.

Analyze the Flight API application

When analyzing the application to determine what application processes you may want to test, you can consider the existing business processes that run in the application.

The business processes that should be tested for the Flight API application include:

  • Connecting to the user database and confirming login information

  • Retrieving the list of flights

  • Retrieving a flight order based on user input

  • Creating a flight order

  • Updating a flight order

  • Deleting a flight order

  • Deleting all flight orders

  • Logging a user out of the application

Although the first and last items above have not yet been implemented in the Flight API application that you want to test, it is important to take them into account in the planning stage.

Now that you have determined the primary application processes, you should analyze each one to determine the breakdown of these application processes into smaller, testable parts.

A logical breakdown of the above business processes could be:

Connecting to the user database and confirming login information
  • Sending a request to connect to the database

  • Receiving confirmation or failure of database connection

  • Checking the customer login details database based on user input

  • Returning authentication results (permission or rejection) for user input

  • Return results to application user interface

Retrieving a list of flights
  • Connecting to the flight information database

  • Receiving confirmation or failure of database connection

  • Searching the flight information database for all available flights

  • Returning the search results

Retrieving a flight order based on user input
  • Connecting to the flight information database

  • Receiving confirmation or failure of the database connection

  • Searching the flight information database using the user-specified criteria

  • Returning the search results

Creating a flight order
  • Connecting to the flight database for the specific flight based on user input

  • Receiving confirmation or failure of the database connection

  • Reserving a place on the selected flight in the database

  • Returning the order confirmation

Updating a flight order
  • Connecting to the flight database and finding the selected flight based on user input

  • Receiving confirmation or failure of the database connection

  • Retrieving the flight order details

  • Updating the flight information in the database based on user input

  • Returning the flight order update confirmation

Deleting a flight order
  • Connecting to the flight database and finding the selected flight based on user input

  • Receiving confirmation or failure of the database connection

  • Retrieving the flight order details

  • Deleting the flight order from the database

  • Returning confirmation of the flight order deletion

By comparing the sub-steps in each of the business processes, you can see what specific steps you need to design in your test. In addition, you can also see the steps that are repeated and can be combined in a reusable action that can be called in different parts of your test.

Back to top

Create or import your test resources

Some of your application processes for the Flight API application require custom activities not included in the standard collection of API activities provided in the Toolbox pane. For these activities, you must import or create the activities into your tests.

At this stage you can import the following Web services methods:

  • CreateFlightOrder

  • GetFlights

  • GetFlightOrders

  • UpdateFlightOrder

  • DeleteFlightOrder

  • DeleteAllFlightOrders

For details on how to import Web Service methods, see Import a WSDL-based Web service.

You can also create the following REST Service resources and methods:

  • Flights Get

  • Flight Get

  • FlightOrders Get

  • FlightOrders ReserveOrder

  • FlightOrder Get

  • FlightOrder Update

  • FlightOrder Delete

  • FlightOrder DeleteAll

For details on how to create REST Service methods, see Create a REST service model.

Back to top

Create your test steps

Now that you have planned and prepared all of the required resources for your test, you are ready to create test steps that represent the steps a real application would perform on the Flight API application.

The activities that are available for your test steps are stored in the Toolbox pane. This includes custom methods that were imported or created for your test:

To create test steps, you select activities from the Toolbox pane and either drag them to the canvas or double-click them to add them to the canvas:

You then set input, output, or checkpoint property values for the activities to mimic your application:

If you have steps that appeared multiple times, you can create an action which combines the repeated steps and call this action instead of the repeated steps.

For task details on creating test steps, see Create an API test.

Back to top

Enhance your test steps

Once you have put the appropriate steps for the Flight API application in the canvas, you can add additional enhancements for these test steps:

  • You can set checkpoint properties for a test step, providing the expected output values for each of the methods.

  • You can link the test steps to a data source, such as an Excel file containing different values for the step input properties. This enables you see how the test steps run with different input values.

  • You can link one step to another. For example, you can link the GetFlights Web Service method to the CreateFlightOrder method to pass the flight information between the two methods.

  • You can add additional event handlers to enhance the step function before the test step runs, during the running of the test step, and after the step's execution.

Back to top

Run the test

After you add your test steps, and provide the input, output, or checkpoint property values, you run your test and observe the results. In the run results, display the Test Flow and observe the results and response for each of the test steps.

If you want to test each individual step after entering its properties, you can right-click the step name in the canvas and select Run Step. UFT One runs only that step and displays the step results in the Run Step Results pane.

Back to top