Data-driven functional tests
Before you begin
About this task
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.
- 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.
- 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, HCL OneTest™ 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
- Create a functional test project.
- Start recording a test script.
- 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.
- Click Finish. The HCL OneTest UI window minimizes and the Recording Monitor opens.
- 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:
- Start the application you want to test and navigate through
the application to the dialog box that you want to data-drive.
- Click Start 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.)
- Perform any actions in the application that you want to record in the test script.
- Click Start Application
- Data-drive the test.
- On the Recording toolbar, click
Insert Data Driven Commands (
).
The test script recording pauses and the Insert Data Driven Actions page opens.
- 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.
- On the Recording toolbar, click
Insert Data Driven Commands (
- 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.
-
- If you choose
Press and drag hand to select test objects, take the following steps:
- Use the mouse to drag the hand, the Object Finder tool
(
), to the object in the application that you want to select.
HCL OneTest UI outlines the object with a red border.
- 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 HCL OneTest UI inserts into the test script to data-drive the application-under-test.
- Use the mouse to drag the hand, the Object Finder tool
(
- 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.
- If you choose the Drag Hand Selection method,
take the following steps:
- Optionally, select or clear After selecting an object advance to the next page.
- Use the mouse to drag the hand, the Object Finder tool
(
), to the object in the application that you want to select.
HCL OneTest UI outlines the object with a red border.
- Release the mouse button.
- Click Next if you did not select After selecting an object advance to next page.
- 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
- If you choose Test Object Browser method,
take the following steps:
- Browse the object tree to find the object that you want to data-drive.
- Click the part of the tree that you want to select.
- Click Next.
- 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
- Click Finish.
The Insert Data Driven Actions page opens with information filled in under Data Driven Commands and Selected Command Description.
- Optionally, in the Data Driven Commands table, under the Variable header, type a descriptive name for the name of each variable in the datapool.
- 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.
- 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
-
- Click OK to finish data-driving the script. The Insert Data Driven Actions page closes and HCL OneTest UI populates a datapool with data collected from the application.
- To finish recording the test script:
- Perform any actions in the application you want to record.
- 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 datapool reference instead of a literal value for the value you are testing in the verification point.
- 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.
- Close your application, if you want closing the application to be part of the script.
- 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 HCL OneTest UI window opens and the script displays in the editor window.
- You can add data to the datapool after you finish recording the test script. For more information about editing a datapool, see Editing Datapools.