Extended Test Script Services Reference |
This class lets a method in a stub access a lookup table.
A lookup table lets you test a component whose operation depends upon an associated component that is still in the development stages. To test the component, you first provide a stub of the unfinished component that contains that component's methods. When the component-under-test calls a method in the stub, the method simulates operation by retrieving information from the lookup table -- information that would otherwise be generated during normal execution in the completed component. The method then presents the retrieved information to the calling component-under-test.
The information that a stub's method retrieves from the lookup table depends upon the values that the component-under-test passes to the method. In other words, a method finds the lookup-table row that contains the parameter values that the component-under-test passed to it, and then retrieves the appropriate value (return value or exception) from that same lookup-table row.
A lookup table typically has multiple rows, with each row representing a different set of inputs and outputs. This allows a method in the component-under-test to be executed multiple times against the stub, supplying different input values and retrieving different output values each time.
In the following example of a lookup table for a mortgage calculation method, amount
, interest
, and months
are input values, while expectedReturn
and expectedError
are the corresponding output values:
Typically, you create a lookup table for each stub method that is called during testing of the component-under-test.
The underlying files used for both lookup tables and datapools are the same. As a result, when it is time to replace the stub with the completed component, you can use the lookup table as a datapool when you test the associated component-under-test.
Note: A stub is not a test script. Consequently, it does not require a TestMain()
method.
The items in this class are members of RTCOMVPLib.LookupTable
.
Commonly used with QualityArchitect.
QualityArchitect is required for use of this class.
The following example opens the lookup table _Account_Info_L
and searches for the lookup table values ParamValues
within the column names ParamNames
. This example also uses the TestLog
methods WriteStubMessage
and WriteStubError
to log status and error information about the lookup table operations.
Private Function Post_LookUp(ParamNames As Variant, ByVal lAccountNo As Long, ByVal lAmount As Long) As String On Error Goto ErrorHandler_Post_LookUp Dim luTable As LookupTable Dim tLog As TestLog Dim ParamValues As Variant Set luTable = New LookupTable Set tLog = New TestLog Err.Clear 'TODO: For complex data types, code below will not be sufficient. 'You will need to add code to generate a meaningful lookup 'call. ParamValues = Array(CStr(lAccountNo), CStr(lAmount)) luTable.Open "_Account_Post_L" 'TODO: For complex data types, code below will need to be Modified. tLog.WriteStubMessage "Account stub, Post method. ", "Entered with following values: " + CStr(lAccountNo) + ", " + CStr(lAmount) luTable.Search ParamNames, ParamValues Dim lErr As Long lErr = luTable.ExpectedException If lErr Then tLog.WriteStubMessage "Account stub, Post method. ", "Raising error: " + CStr(lErr) On Error GoTo RaiseError_Post_LookUp Err.Raise lErr, "RQA", "Error raised from stub for Account.Post" On Error GoTo ErrorHandler_Post_LookUp Else 'TODO: For complex return types, code below will not be 'sufficient. You will need to add code to generate a meaningful 'return value. Post_LookUp = luTable.ReturnValue End If luTable.Close Exit Function ErrorHandler_Post_LookUp: tLog.WriteStubError Err.Number, Err.Source + ": " + Err.Description luTable.Close Exit Function RaiseError_Post_LookUp: Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext luTable.Close End Function
This class contains the following properties:
This class contains the following methods:
Open
Opens the specified lookup table.
Close
Closes the lookup table.
Search
Sets the cursor to the row in the current lookup table that contains the column value(s) passed to it.
Opens the specified lookup table.
Open
(TableName
As String)
TableName
The name of the lookup table to open.
Only one lookup table can exist for a given instance of the LookUpTable
class.
Close()
This function only works if LookUpTable.Open has been called.
Sets the cursor to the row in the current lookup table that contains the column value(s) passed to it.
Search
(ParamNamesArray
() As String,ParamValuesArray
() As String) As Boolean
ParamNamesArray
An array containing one or more lookup-table column names.
ParamValuesArray
An array containing a value for each corresponding column name passed to the method.
If TRUE
, the cursor was successfully set to the row that matched the specified criteria.
If FALSE
, a row could not be found that matched the specified criteria.
Subsequent value-retrieval methods act upon the row with the cursor.
If multiple rows contain the passed value(s), FALSE
is returned.
Rational Test Script Services for Visual Basic | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |