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.
- Multiplications (All possible combinations right from 1, 2, 3…… to 999999…..)
- All possible Subtractions
- All possible Additions
- 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.
- Invoke QTP .
- Click Record and invoke the calculator application. The following code will get generated SystemUtil.Run “calc”,””,”C:\Documents and Settings\abhinav”,””
- Click view datatable.
- 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)
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.
Figure 4: Test Results
That’s the fun of doing Automation !!!