QTP – A brief Primer on Data Driven Implementation

QTP – A brief Primer on Data Driven Implementation

 

Introduction to data driven support in QTP : QTP has some very practical usages which require very little time investment, encounter no tool complexities, but has huge benefits. The current topic demonstrates one such implementation.
Lets us say that you have a calculator application and you want to test all possible numeric combinations with all the available operators. I am just talking about the simple calculator (not scientific) Here are the test steps/cases:

Invoke the Application. Use all possible numeric combinations to perform all the possible calculations as mentioned below.

  1. Multiplications (All possible combinations right from 1, 2, 3…… to 999999…..)
  2. All possible Subtractions
  3. All possible Additions
  4. Divisions
  5. Close the Application

Total number of manual Test cases would be in thousands and time taken would be in hours. Still zero accountability/proof whether the tester has actually executed the tests or spent the entire day

playing video games (BTW, it does happen).

In order to automate the test application, perform the following steps:

Prepare a matrix of all the possible numeric combinations with all the available operations (for example 12345679*8=) in an excel sheet and save it in a predefined location.

  1. Invoke QTP .
  2. Click Record and invoke the calculator application. The following code will get generated SystemUtil.Run “calc”,””,”C:\Documents and Settings\abhinav”,””
  3. Click view datatable.
  4. In order to do the calculations of the test cases (multiple operator tests of variousnumerical data sets), type the following command: Window(“Calculator”).Type DataTable(“DataTable123456798_param_dtGlobalSheet”, dtGlobalSheet)

Click File – Settings. The Test Settings dialog box as displayed in Figure 1 will get displayed.

Figure-2-Test-Settings

  1. Click the Run tab. Following screen will be displayed. It has the radio buttons which need to be selected for the no of iterations you look forward to run.
QTP - Iteration - Test-Settings

QTP – Iteration – Test-Settings

    Select run on all rows radio button.

Figure 2: Test Settings — Run
8. Click the Resources tab. The following dialog box will be displayed. Under the

data table option, browse to select the xls file created for test cases.

Note: There is a dependency on the naming convention of the excel file which needs to match the name of the action name specified in the code. QTP does prompt with an information dialog box as shown below.

9. Close the Application/Calculator using Window(“Calculator”).Close. The QTP will have just 3 lines of Test code as displayed below:

Figure 3: Code Window Run the test. Observe/Record the Results.

The entire test with all the specified data will get executed. The following result will get displayed after the successful completion of the tests.

QTP_test_execution_results

QTP_test_execution_results

Figure 4: Test Results

That’s the fun of doing Automation !!!

 

 

Submit a Comment

Your email address will not be published. Required fields are marked *

Skip to toolbar