Tutorial 4: Example on Data driven Testing using TestComplete

In the previous article, we learn about Data-Driven Testing Procedure And Its Implementation Using TestComplete. In today’s class, we will learn about Data-driven testing using TestComplete.

Many software applications irrespective of the web or mobile app require being tested functionally based on the input data. Such type of functional testing where we run automated tests in order to simulate user actions on an application (web or mobile) with variable input data is known as data-driven testing. Data-driven testing provides large test coverage to ensure that application works smoothly against different input data. TestComplete is one of tool that supports Data-driven testing and in this chapter we are going to learn about its various data-driven testing features as well as how to create tests of such type of testing by using this tool.

 

Example on Data driven Testing

 

1) Basic Concepts for Data-Driven Testing:

In automation testing, we play back the recorded automated tests as a sequence of user actions which cover a certain functionality of the tested application.Usually, any data-driven test executes the following tasks in a loop:

  • Firstly, it retrieves the required test data from a data storage. Data storage could be excel, CSV, or database tables.
  • Secondly, it enters the data in an application form or screen in case of web application and simulates user actions.
  • Thirdly, it verifies results as expected value against actual value returned.
  • Lastly, it goes into a loop to continue testing with the next set of input data after recording the result for this iteration.

2) Data preparation for the Data-Driven Testing:

To conduct any data-driven testing, the key point is to select the most appropriate test data so that in the minimum number of steps, one can observe maximum test coverage. The following are the steps to prepare test data storage.

  • Generation of test data: TestComplete tool provides “Data Generation” feature to generate test data. Using this feature, we can create an Excel file or a Table variable which can store generated data. To accomplish this, just open the Data Generator wizard and provide your desired parameters in it. This generated data can we use in our tests. For example, this wizard can create an Excel file with the required number of columns where we can specify a data type for each column along with limits for the values which will be stored to the file.
  • Creation of a Table variable: We can prepare a TestComplete Table variable which can store test data that can be used for executing our tests. Here, we have to manually specify the data stored in a variable. Such variable to store data can be created by using the following features of the TestComplete tool. They are Add Variable, Add Variable to Keyword Test or Data Generator wizard of TestComplete.
  • Creation of an external file manually: In TestComplete, we can create an external file manually to populate it with the required test data. Here, we have to use the DDTDriver program object and its methods in order to use data in our test.

3) Creating and using Scripts for Data-Driven Testing:

We can create data-driven tests with scripts, where we need to iterate in a loop through the test data. Loops in the test script can be created through the ‘for’or‘while’ statements. The instructions in the test script allow retrieving data from the data storage while iterating in a loop, enter these data values into the application form and verify the results against expected values.

4) Using Keyword Tests for Data-Driven Testing:

In TestComplete tool, we can retrieve data from a data storage and prepare data loops in keyword tests with the help of the Data-Driven Loop operation. Data-driven loop operation allows is to get retrieve data to Excel files, CSV files and database tables by simply iterating over their records.

5) Using DDT Drivers:

In TestComplete tool, we can easily use DDT driver objects to extract data stored in the database tables via Microsoft ADO, from external Excel sheets a comma-separated value (CSV file). We can procure a driver object in our test script, by calling one of the following methods of the DDT object:

  • ADODriver –ADODriver helps to create a driver for a recordset that can be accessed via Microsoft’s ADO DB.
  • CSVDriver –As the name suggests, it helps to create a file to hold values separated by commas.
  • ExcelDriver – As the name suggests, it helps to create a driver for a sheet as an Excel document.

6) Establishing Data Storages:

In the TestComplete tool, we can use any data storage we need from comma-separated values (CSV) files, database tables, Excel sheets, script arrays, table variables, etc. The TestComplete tool has many special built-in routines and program objects which help in extended support for our data-driven testing.

 

Data driven loop select table type

 

7) Data storage:

a) Use of Excel Files:

The TestComplete tool allows storing data into external Excel files with multiple columns. These external excel files can be imported into the TestComplete tool and can be used as data storage for our data-driven testing.

b) CSV Files:

The TestComplete tool allows storing data into external CSV (comma-separated values) files with multiple columns. These external CSV files can be imported into the TestComplete tool and can be used as data storage for our data-driven testing.

c) Database Tables:

The TestComplete tool allows to store data into database tables with multiple columns and each column can have data types as a character, number, etc. The database table data can be imported into the TestComplete tool and can be used as data storage for our data-driven testing.

8) Data-Driven Testing – Retrieving Input Data from Data Storage:

TestComplete tool allows to store test data into comma-separated values (CSV) files, database tables, Excel sheets, script arrays, table variables, etc. which can be retrieved through test scripts (or programming) and used to fills various field on the application form in order to verify the output result against expected results.

9) Using Data Generators:

Data Generators in TestComplete allows generating test data that can be saved in the TestComplete table or an Excel file. It also allows populating data storages with randomly generated data.

 

Conclusion

In this chapter, we have discussed step by step approach that can be used to create a test script along with the data storage in order to accomplish data-driven testing using a TestComplete tool.

Next tutorial: Why TestComplete is the most suitable tool to automate Android OS


⇓ Subscribe Us ⇓


If you are not a regular reader of this website then highly recommends you Sign up for our free email newsletter!! Sign up just providing your email address below:

Enter your email address:

Check email in your inbox for confirmation to get latest updates Software Testing for free.

Happy Testing!!!

1 thought on “Tutorial 4: Example on Data driven Testing using TestComplete”

Leave a Comment

Share This Post