A typical data-driven test performs the following operations:
Connects to a data storage.
Performs the following actions in a loop:
Read a portion of data from the data storage.
Input the data into edit fields of an application’s form.
Verify the results.
TestComplete includes special means that simplify performing these actions in keyword tests. This topic describes them:
1. Retrieve Data and Iterate Through Storage
Using the Data-Driven Loop Operation
To retrieve data from a storage and create data loops in keyword tests, you can use the Data-Driven Loop operation. This operation allows you to get access to Excel files, CSV files and database tables and iterate through their records. For more information on using the Data-Driven Loop operation, see Creating Data-Driven Loops.
For a step-by-step description of creating data-driven tests with keyword tests, see Data-Driven Testing With Keyword Tests - Tutorial.
Using Scripting Methods and Routines
To retrieve data from a storage and iterate through rows, you can also call special scripting methods and routines which TestComplete provides for data-driven testing:
|Returns a driver object for the specified database table. The test engine connects to this table via ADO.
|Returns a driver object for the specified CSV file.
|Returns a driver for the specified Excel sheet.
|These methods are used to process a list of strings. To parse comma-separated values, you should assign a comma (",") to the
For more information on these routines, see Using Scripts for Data-Driven Testing.
Enter Data Into an Application’s Form
To enter data into application forms and controls, you either simulate keystrokes or mouse clicks, or store the desired value directly to a property of the desired form or control.
In many cases, the easiest way to understand how to simulate the appropriate input is to record a test using one portion of test data and see how TestComplete does this. You can then modify this test so that it assumes input data as parameters.
The following notes may help you with creating a test that simulates user input:
To simulate mouse actions over list boxes, combo boxes, tree views, list views and other controls, use specific methods of these objects. See Working With Application Objects and Controls.
If your tested application is compiled as an Open Application, you may call methods defined by the application code or assign values directly to properties of application’s internal objects. To call the methods and assign properties, you can use the On-Screen Action, Call Object Method and Run Code Snippet operations.
- To change the type of the data you retrieve from a storage, use the
VarToIntmethod. See Retrieving Input Data From Storage.
For information on simulating user input, see also Simulating User Actions.
Verify Test Action Results
To verify that the tested application works as expected, you compare the application’s output with some expected values. For instance, if you test an Edit Order form, you may check that the total sum of an order is calculated with the appropriate discounts.
A good practice is to store the baseline values along with the test data in the data storage and use the baseline value for each portion of test data (that is, for each row). See Organizing Data Storages.
To compare data and values we recommend that you use TestComplete checkpoints. If the output is an image, file or database table, you can use checkpoints of the appropriate type to compare images, files and data tables. To compare individual property values, you can also use the If... Then and Else operations.
Our web site has an article that describes how to use keyword tests to create data-driven tests in TestComplete:
Data-Driven Testing - Basic Concepts
Preparing Data for Data-Driven Testing
Using Scripts for Data-Driven Testing
Organizing Data Storages
Creating Data-Driven Loops
Data-Driven Testing With Keyword Tests - Tutorial