Using Keyword Tests for Data-Driven Testing

Applies to TestComplete 14.70, last modified on April 22, 2021

A typical data-driven test performs the following operations:

  1. Connects to a data storage.

  2. 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:

Routine Description
DDT.ADODriver Returns a driver object for the specified database table. The test engine connects to this table via ADO.
DDT.CSVDriver Returns a driver object for the specified CSV file.
DDT.ExcelDriver Returns a driver for the specified Excel sheet.
aqString.GetListLength, aqString.GetListItem These methods are used to process a list of strings. To parse comma-separated values, you should assign a comma (",") to the aqString.ListSeparator property.

For more information on these routines, see Using Scripts for Data-Driven Testing.

To call these routines from your keyword test, use the Run Code Snippet and Call Object Method operations.

To implement a loop, use the While Loop or For Loop keyword test operations.

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:

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.

Web Article

Our web site has an article that describes how to use keyword tests to create data-driven tests in TestComplete:

Introduction to Data-Driven Testing in TestComplete

See Also

Data-Driven Testing
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

Highlight search results