A typical data-driven test performs the following operations in a loop:
- Retrieves input data from storage
- Enters it in an application form
- Verifies the results
- Continues with the next set of input data
For instance, often data is stored in a text file and are separated by commas (CSV). This lets you modify them easily. If you need to add more data, you simply modify the file in any text editor (in case of hard-coded values, you should modify both data and code). Each string in the file holds values to be assigned or checked. Normally, each string holds values for one test. However, you are free to use several strings for one test. In this case, you may need to add a field that will specify which values are input, and which are verifying values.
For information on data storages that TestComplete supports, see Data Storages.
TestComplete includes special keyword test operation, built-in routines and program objects that provide extended support for data-driven testing.
Keyword Test Operations
To simplify access to data stored in Excel sheets, ADO databases or CSV files from keyword tests, TestComplete includes the special Data-Driven Loop keyword test operation that allows you to create data-driven loops and iterate through the storage’s records. When you are adding this operation to the test, you specify the DB Table variable that will access the specified storage, and specify the records that will be processed by the operation.
You can also retrieve data from TestComplete Table variables. For this purpose, use the Data-Driven Loop keyword test operation. Note that you can specify the default data that will be stored in the variable manually or generate test data using a special TestComplete wizard.
||This object provides access to drivers that let you easily extract data from Excel spreadsheets, database tables and CSV files.|
||These methods are used to process a list of strings. To parse comma-separated values, you should previously assign a comma (",") to the
||Evaluates an expression or executes a routine by its name.|
||Calls an object's method by the method name.|
||Retrieves and sets a property value by its name.|
The last three methods,
SetPropertyValue, let you modify the methods sequence and properties to be called by a script without having to modify the script code.
To simplify access to data stored in Excel sheets, ADO databases or CSV files, TestComplete includes special driver objects that hide the actual data storage format and let you access data using a unified table-like interface. For instance, each row of a CSV file is represented as a table record, and a value in this row is presented as a column value.
To work with the drivers, use the
DDT object. Its methods let you obtain driver objects for Excel sheets, ADO tables and CSV files:
||Returns a driver object for the specified ADO table.|
||Returns a driver object for the specified CSV file.|
||Returns a driver for the specified Excel sheet.|
Changing the Data Type of the Retrieved Value
TestComplete uses DDT Drivers to retrieve information from a storage. In most cases, the data is retrieved as a string. However, it can also be retrieved as an integer. Some methods perform different actions depending on whether you use integers or strings. For example, the ClickItem action performs a touch on an item using its index if you use an integer, but if you use a string, it searches for the corresponding item caption.
To use these methods in keyword tests, do the following:
- Double-click the Value cell of the Keyword Test operation to open the Parameters Editor.
- Click the ellipsis button.
- Copy the contents of the Value field to the Clipboard.
- Change the Mode option to Code Expression.
- In the value column, type in either
- Paste the Clipboard contents inside the parentheses and click OK.
In scripts, use these methods to change the data type of the value you retrieve, for example,