Data-driven 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.


Before you begin

A datapool can be populated with data from the application. A datapool is a collection of related data records. A datapool 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:

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 box, in the Datapool Record Selection Order box, select one of the following types of datapool record selection orders:

      • Sequential -- At playback, the test script accesses records in the datapool in the order that they appear in the datapool.

      • Random -- At playback, the test script randomly accesses every record in the datapool once.

    2. Click Finish. The Functional Tester window minimizes and the Recording Monitor opens.

  3. Start the application you want to test and navigate through the application to the dialog box that you want to data-drive.

    1. Click Start Application on the Recording toolbar.

      See Start 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 ().

      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 datapool 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:

    • 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 -- 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 Press and drag hand to select test objects, take the following steps:

    1. Use the mouse to drag the hand, the Object Finder tool (), to the object in the application that you want to select.

      Functional Tester 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 Functional Tester inserts into the test script to data-drive the application-under-test.

  7. If you choose 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.

    • 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 (), to the object in the application that you want to select.

      Functional Tester 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 datapool.

  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.

    • Click to move the selected row earlier in the order of execution in the Data Driven Commands table.

    • Click to move the selected row later in the order of execution in the Data Driven Commands table.

    • Click to delete a selected row from the Data Driven Commands table.

    • 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.

    • 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 Functional Tester populates a datapool 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 Create a Properties Verification Point for an example of how to create a properties verification point.

      You can use a datapool 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 box 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 () to write all recorded information to the test script and update the datapool with new variables and associated initial values.

      The Functional Tester window opens and the script displays in the editor window.

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


Related concepts

Data-driving tests overview

Related tasks

Associating functional test scripts with the keywords

Recording a Java test script

Related reference

Field separators for datapools