Tutorial 3: Data-Driven Testing Procedure And Its Implementation Using TestComplete

As discussed in the last chapter of this tutorial, the TestComplete tool has an inbuilt test data generator which can quickly generate a lot of data that can be used in the test scripts. The tool allows to retrieve data from CSV files, workbooks or database tables and you can run automated tests for different data sets using this tool. It is always recommended to separate test data from test scripts for low test maintenance and more flexibility. In this chapter, we are to discuss and learn about the TestComplete Data-Driven Testing procedure and its implementation using this tool.

 

TestComplete Data-Driven Testing:

Data-driven testing (DDT) is a testing technique that is widely used in the software industry to test computer software. It describes testing which is done by using a table of conditions directly as test inputs and demonstrable outputs.It also describes the process where the test environment settings and controls can be easily created and switched without hard coding any configurable values. In this technique, the tester provides the inputs from a row in the table and expects the outputs in the same row but different column. The table is prepared to contain the values which correspond to partition or boundary input spaces. Such values can also be configured in a database and read as boundary input spaces in the control methodology.

 

TestComplete Data-Driven Testing

 

TestComplete – Create new project:

To start working with TestComplete, first of all, we need to create a new project in TestComplete. Click on New Project link present on the top left corner, it will open a dialogue box where you need to provide the project name and location where this project has created on your machine as shown below. Once project name and location is provided click Next to choose the type of project you want to test.

 

TestComplete New Project

 

TestComplete is a versatile testing tool that supports the testing of Generic Windows application, functional testing of web pages, android applications, iOS applications, Web service testing, Adobe AIR and Windows store application testing. In this chapter, I have selected functional testing of web pages and clicked next button.

 

TestComplete Project Type

 

On the next page, you will be asked to choose the type of scripting language you have used in the project that you want to test. TestComplete supports JavaScript, Python, VBScript, DelphiScript, and JScripts. I have chosen JavaScript as a scripting language for the functional testing of Web pages as shown below. Click on the finish button to complete the creation of a test project in TestComplete tool.

 

TestComplete New Project Lanuguage

 

Once the project is created, you can observe on the left-hand side the associated test script file with the test project we have created as shown below.

 

TestComplete project suits
⇑ Click image to enlarge ⇑

All project suits have associated project suite log package where all project logs are created for all tests as they are executed. We can create a simple test project and go to use a data-driven loop to create data-driven testing. In the coming test, we are going to test multiple website links and going to procure the page title. Therefore, in the data-driven testing, we are going to provide data through an excel sheet using TestComplete.

To start with, click on the Data Access link present in the workspace on the left-hand side as shown below. It will open up the data-link loop option on the left-hand side.

TestComplete DataAccess

Once you click on the data-driven loop option. It will ask you to select or create new data variable. Here, we are going to create a new data variable as `var1` and click on the next button. On the next page, you will observe that there are multiple options through which you can read data into test complete tool. The available options are excel worksheet, CSV file, database table, database query, and table variable. Choose the option as excel worksheet and click on the next button.

TestComplete Data Driven Loop

On the next page, it will ask you to either edit workbook or browse the Excel workbook from the local machine.

TestComplete Excel Workbook

We have created an excel workbook which has the following two rows and two column data in it as shown below.

TestComplete Data Sheet

After importing the excel workbook, the tool will ask for the beginning and end record for the table for the data-driven loop as shown below. Choose the default setting and click on the Finish button to complete the creation of Data-driven loop in TestComplete tool.

TestComplete Select Records

Creating the test recording it

Test case creation and running it very simple and it can be accomplished by using record and play option present in the TestComplete tool. We can simply add a new test by right click on the project – Add – New item. This will create the test and we can now use the record option to record the test. In this test, we are going to load the URL from the data table on the Chrome browser which requires a SmartBear Test Extension to be installed and enabled in Chrome browser. Therefore, add this extension to the Chrome browser as shown below.

SmartBear Test Extension

Once this extension is enabled, we can load the URL and get the title of that web page. The expected output can be matched against the actual output received (here web page title) and TestComplete can pass or fail the test.

In this test, we have used a data-driven approach where the input data is read from the excel workbook to load the URL in the Chrome browser. After the web page is loaded successfully, we get the page title which is matched against the expected output present in the 2nd column of the excel workbook and test is looped automatically for the number of rows provided and the test result as pass or fail is recorded in the TestComplete logs. The TestComplete tool has the capability to maintain the history of test logs each time they are executed.

Conclusion

The TestComplete tool is one of the best tool to conduct the data-driven testing for Web testing, desktop app testing as well as mobile app testing. Therefore, it is also popularly known as the all-inclusive testing tool and most preferred in many organization for their automation regression testing.

Leave a Comment

Share This Post