Data-Driven Testing Framework
Data-driven testing is a framework where test input and output values are read from data files (datapools, ODBC sources, cvs files, Excel files, DAO objects, ADO objects, and such) and are loaded into variables in captured or manually coded scripts. In this framework, variables are used for both input values and output verification values. Navigation through the program, reading of the data files, and logging of test status and information are all coded in the test script.
This is similar to table-driven testing in that the test case is contained in the data file and not in the script; the script is just a "driver," or delivery mechanism, for the data. Unlike in table-driven testing, though, the navigation data isn't contained in the table structure. In data-driven testing, only test data is contained in the data files.
The IBM Rational toolset has native data-driven functionality when using the SQABasic language and the IBM Rational datapool structures. To demonstrate the use of this framework, we'll test the order form from the test sample application Classics A (see Figure 2).
Order form from the sample application:

If we record data entry into this window, we get the following:
'Data Driven Framework'Test Case Script
Sub Main
'Make An Order
Window Set Context, "Name=frmOrder", ""
'Card Number
EditBox Click, "Name=txtCreditCard", "Coords=16,9"
InputKeys "3333444455556666"
'Expiration Date
EditBox Click, "Name=txtExpirationDate", "Coords=6,7"
InputKeys "3333444455556666"
'Place Order
PushButton Click, "Name=cmdOrder"
'Confirmation Screen
Window SetContext, "Name=frmConfirm", ""
PushButton Click, "Name=cmdOK"
End Sub
We can use datapools to set up test cases that test valid and invalid credit card numbers and expiration dates. The datapool shown in Figure 3, for example, would be for a test case that would test the date field.
Figure 3. Sample
datapool for a test case that would test the date field

If we modify the script to accept this data, we get the following:
'Data Driven FrameworkThe SQABasic commands were added to manipulate the datapools. We also added a'Test Case Script
'$Include "SQAUTIL.SBH"
Sub Main
Dim Result As Integer
Dim DatapoolHandle As Long
Dim DatapoolReturnValue As Variant
'Open the datapool
DatapoolHandle = SQADatapoolOpen("OrderFormDP")
'...Add error checking....
'Loop through the datapool
While SQADatapoolFetch(DatapoolHandle) = dqaDpSuccess
'Open Order Form
Window SetContext, "Name=frmMain", ""
PushButton Click, "Name=cmdOrder"
Window SetContext, "Name=frmOrder", ""
'Card Number
Result = SQADatapoolValue(DatapoolHanle, "Credit Card Number", DatapoolReturnValue)
"...Add error checking....
EditBox Click, "Name=txtCreditCard", "Coords=16,9"
'...Clear Value....
InputKeys DatapoolReturnValue
'Expiration Date
Result = SQADatapoolValue(DatapoolHandle, "Expiration Date", DatapoolReturnValue)
'...Add error checking....
'...Clear Value...
EditBox Click, "Name=txtExpirationDate", "Coords=6,7"
InputKeys DatapoolReturnValue
'Place Order
Result = SQADatapoolValue(DatapoolHandle, "Order", DatapoolReturnValue)
If UCASE(DatapoolReturnValue) = "YES" Then
PushButton Click, "Name=cmdOrder"
'Confirmation Screen
Window SetContext, "Name=frmConfirm", ""
Pushbutton Click, "Name=cmdOK"
Else
PushButton Click, "Name=cmdCancel"
End If
Wend 'Go fetch next row
'Close datapool
Result = SQADatapoolClose(DatapoolHandle)
'...Add error checking....
End Sub
While loop to allow for the processing of each row in the datapool. Please also check the use of the SQABasic command UCase within the If Then statement. UCase is used to make the argument (in this case, the datapool return value) all uppercase. This way the comparisons aren't case sensitive, making the code more robust.This framework tends to reduce the overall number of scripts you need in order to implement all of your test cases, and it offers the greatest flexibility when it comes to developing workarounds for bugs and performing maintenance. Much like table-driven testing, data-driven testing requires very little code to generate many test cases. This framework is very easy to implement using the IBM Rational toolset, and there's a lot of detailed documentation available with how-tos and examples.