Data-driving functional tests

To data-drive a test script, you need to select the controls or objects in the application-under-test using either the Object Finder Tool method or the Test Object Browser method.

About this task

A dataset can be populated with data from the application. A dataset is a collection of related data records. A dataset supplies data values to the variables in a test script during test script playback.

You can use any of the following methods to select an object or a control:
  • Object Finder Tool method -- Use this tool to select an object and all descendents of the object, select one object, or select an object and the immediate children of an object.
    Note:
  • Test Object Browser method -- Use this method to browse for the object that you want to select. The browser displays a hierarchical tree of objects in your application. The top level shows any applications you have running. Under each top level, Test UI displays the object hierarchy within that application. The hierarchical tree is a dynamic view of the currently available objects.

To data drive a test script:

Procedure

  1. Create a functional test project.
  2. Start recording a test script.
    1. In the Select Script Assets dialog, in the dataset Record Selection Order box, select one of the following types of dataset record selection orders:
      • Sequential -- At playback, the test script accesses records in the dataset in the order that they appear in the dataset.
      • Random -- At playback, the test script randomly accesses every record in the dataset once.
    2. Click Finish.
      The Test UI window minimizes and the Recording Monitor opens.
  3. Start the application you want to test and navigate through the application to the that you want to data-drive.
    1. Click Start Application Starts an application on the Recording toolbar.

      See Starting Your Test Applications for more information. (If your application is already running, you do not need to do this step.)

    2. Perform any actions in the application that you want to record in the test script.
  4. Data-drive the test.
    1. On the Recording toolbar, click Insert Data Driven Commands (Inserts data driven commands).

      The test script recording pauses and the Insert Data Driven Actions page opens.

    2. In the application-under-test, type the initial values that you want to see in the dataset in the fields that you want to data drive.

      By populating these fields while the recorder pauses, you do not record unnecessary actions in the test script. Any change to the control flow of the program while the test script recording pauses is not recorded in the test script.

  5. Under Populate then Select Test Objects, choose one of the following methods:
    • Object Finder Press and drag hand to select test objects -- Use this method to select an object and all the descendents of the selected object. This is the most common and direct method of selecting an object.
    • Use selection wizard to select test objects Use selection wizard to select test objects -- Click to use the Drag Hand Selection method with its options, or the Test Object Browser method. The Select Object to Data Drive page opens.
  6. If you choose Object Finder Press and drag hand to select test objects, take the following steps:
    1. Use the mouse to drag the hand, the Object Finder tool (Object Finder), to the object in the application that you want to select.

      Test UI outlines the object with a red border.

    2. Release the mouse button.

      The Data Drive Actions page opens. In the Data Drive Actions page, under the DataDriven Commands table, information appears about the objects you selected.

      You can place your mouse pointer over a row in this table to view the line of code that Test UI inserts into the test script to data-drive the application-under-test.

  7. If you choose Use selection wizard to select test objects Use selection wizard to select test objects, click the Selection method arrow to select one of the following methods:
    • Drag Hand Selection method -- Use this tool to include only the selected object, the selected object and the immediate children of the selected object, or to include the selected object and all descendents of the selected object.
      Note: The Drag Hand Selection method is not available on Linux environments such as Ubuntu and Red Hat Enterprise Linux (RHEL). You must use the Test Object Browser method on Linux environments.
    • Test Object Browser method -- Use this method to browse for the object that you want to select.
  8. If you choose the Drag Hand Selection method, take the following steps:
    1. Optionally, select or clear After selecting an object advance to the next page.
    2. Use the mouse to drag the hand, the Object Finder tool (Object Finder), to the object in the application that you want to select.

      Test UI outlines the object with a red border.

    3. Release the mouse button.
    4. Click Next if you did not select After selecting an object advance to next page.
    5. Click one of the following options:
      • Just the selected object
      • Include the immediate children of the selected object
      • Include all descendents of the selected object
  9. If you choose Test Object Browser method, take the following steps:
    1. Browse the object tree to find the object that you want to data-drive.
    2. Click the part of the tree that you want to select.
    3. Click Next.
    4. Choose one of the following options:
      • Just the selected object
      • Include the immediate children of the selected object
      • Include all descendents of the selected object
    5. Click Finish.

      The Insert Data Driven Actions page opens with information filled in under Data Driven Commands and Selected Command Description.

  10. Optionally, in the Data Driven Commands table, under the Variable header, type a descriptive name for the name of each variable in the dataset.
  11. Optionally, in the Data Driven Commands table, under the Initial Value header, double-click the initial value, and then type in a new initial value or click the arrow to select a new value from the list.

    For example, you can change the initial value of a test object to test the non-default states of an application.

  12. Optionally, in the Data Driven Commands table, make any of the following changes.
    • Moves selected row earlier in the commands table Click to move the selected row earlier in the order of execution in the Data Driven Commands table.
    • Moves selected row later in the commands table Click to move the selected row later in the order of execution in the Data Driven Commands table.
    • Deletes the selected for from the commands table Click to delete a selected row from the Data Driven Commands table.
    • Highlights the selected test object in the software under test Click to highlight a test object in the application-under-test. Select a test object in the Data Driven Commands table, and then click this icon.
    • Displays or hides recognition and administrative properties Click to display or hide recognition and administrative properties for a selected test object
  13. Click OK to finish data-driving the script. The Insert Data Driven Actions page closes and Test UI populates a dataset with data collected from the application.
  14. To finish recording the test script:
    1. Perform any actions in the application you want to record.
    2. If you want to record a verification point, locate the object in your application you want to test, and then click the Insert Verification Point or Action Command button.
      Tip: Click the Help button while creating the verification point for more information on the Verification Point and Action Wizard, or see Creating a Properties Verification Point for an example of how to create a properties verification point.

      You can use a dataset reference instead of a literal value for the value you are testing in the verification point.

    3. If you want to insert any script support functions into the script, such as a call script command, log entry, timer, script delay command, or comment, click the Insert Script Support Commands button.

      Click the Help button in the Script Support Functions dialog for information on these functions.

    4. Close your application, if you want closing the application to be part of the script.
    5. On the Recording toolbar, click Stop Recording (Stop Recording) to write all recorded information to the test script and update the dataset with new variables and associated initial values.

      The Test UI window opens and the script displays in the editor window.

  15. You can add data to the dataset after you finish recording the test script. For more information about editing a dataset, see Editing datasets.