Data-Driven Testing - Basic Concepts

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

This topic provides you with general information on Data-Driven testing:

About Data-Driven Testing

Automated tests play back a recorded (or programmed) sequence of user actions that cover a certain area of the tested application. To get larger coverage, you can perform tests with different input data. Suppose, for example, you recorded actions that input data into an application’s form. The recorded test contains only those values that you entered during the recording and, most likely, these values do not cause errors in the application, but other data may cause them. So, you have to run your test with different set of input data to ensure that the application works as expected for various input values. This testing approach is called data-driven testing.

Of course, you can record many tests with various input data, but the best solution is to separate data from test commands. Data-driven tests will read data from data storages, for example, from a file or database, rather than use hard-coded values. Such a separation makes tests logically simpler. A test containing several sets of hard-coded values can be rather difficult to modify and maintain. For instance, if you need more input data, you will have to modify the test commands.

Data Storages

For data-driven tests in TestComplete, you can use the following types of data storages:

Note: Normally, the storages contain both input data and verifying values. This approach let you easily specify verification data for each portion of test data.

To prepare and access your test data, see Preparing Data for Data-Driven Testing.

To organize your test data files, see Organizing Data Storages.

Common Tasks

Typically, a data-driven test performs the following operations in a loop:

  1. Retrieves the portion of test data from a storage.

  2. Enters the data in an application form and simulates other actions.

  3. Verifies results.

  4. Continues testing with the next set of input data.

TestComplete includes special scripting functions and objects that simplify performing these steps. These objects, for instance, let you easily extract data from CSV (comma-separated values) files, database tables and Excel worksheets. For more information, see the following topics:

Samples

TestComplete also includes a sample project that illustrates data-driven testing:

Data:

<TestComplete Samples>\Common\Data-Driven Testing\TestBook.xlsx

TestComplete project suites:

<TestComplete Samples>\Common\Data-Driven Testing\Scripts

Note: If you do not have the sample, download the TestComplete Samples installation package from the support.smartbear.com/downloads/testcomplete/samples/ page of our website and run it.

How Do I Start?

Follow the step-by-step instructions to learn how to create data-driven tests step by step:

You can explore the following script example to learn how to use an Excel file as a data source for your test and how to extract data from the Excel file:

Using the DDTDriver Object to Retrieve Data From Excel Files

To learn more about data-driven testing, you can also read the following article:

http://vig.pearsoned.com/samplechapter/0131838806.pdf

Note: To view this file you must have Adobe Acrobat Reader installed.

Remarks

When iterating through data sets, you can use the Log.AppendFolder, Log.PopLogFolder, and Log.PushLogFolder methods, or the aqTestCase.Begin and aqTestCase.End methods to isolates operations performed for each data set. The aqTestCase.Begin and aqTestCase.End methods will also add each iteration to the Summary report as a separate test case.

See Also

Data-Driven Testing
Using Keyword Tests for Data-Driven Testing
Using Scripts for Data-Driven Testing
Organizing Data Storages
Using Excel Files as Data Storages
Using CSV Files as Data Storages
Using Database Table as Data Storages

Highlight search results