RTCOM Support Class |
The Rational Test Component Object Model (RTCOM) class provides functions specific to the COM protocol. Visual Basic scripts that are generated from COM sessions use RTCOM class methods for error handling, datapool configuration, object monitoring, and logging operations.
In generated scripts, RTCOM methods are invoked through rtcom
, a variable holding an object reference instantiated as follows:
Private RTCOM As New TestScriptServicesLib.RTCOMSupport
This is not shown in the examples.
The following table lists and describes the RTCOM member functions.
Specifies the list of expected errors for the application under test.
ErrorArray
GetDatapoolAccessFlags
Gets datapool access flags from the resource file.
GetDatapoolOverrideList
Gets datapool override column name/values from the resource file.
Monitor
Controls COM object monitoring.
SetCMDID
Sets the command ID for a COM method call.
Specifies the list of expected error for the application under test.
ErrorArray
(errList
as Long)
errList
An array of Longs specifying HRESULT values that should not be regarded as errors.
This method generates one of the following status codes:
S_OK
. Success.
ERROR_TSS_ABORT
. Abort in progress, probably resulting from a user request.
ERROR_INVALID_PARM
. A required argument is missing or invalid.
ERROR_GET_TLS_INDEX
. An internal storage error (unrecoverable) occurred.
ERROR_OUT_OF_MEMORY
. An attempt to allocate dynamic memory failed.
When a method completes, the COM interception mechanism within TSS needs to decide whether the method succeeded or failed. Without guidance, the mechanism considers any HRESULT that has the error bit on to be a failure. It is possible that, for the application under test, certain HRESULTs that have the error bit set do not indicate failure. Use ErrorArray
to pass any such HRESULTs to the interception mechanism so that it does not consider them failures for the application under test.
This example passes three HRESULT values to the interception mechanism, so that it does not consider them to indicate failure.
Dim expectedErrs(2) As Long
expectedErrs(0) = 0
expectedErrs(1) = &H80040001
expectedErrs(2) = &H80040123
rtcom.ErrorArray expectedErrs
Gets datapool access flags from the resource file.
GetDatapoolAccessFlags() As Long
A 32-bit integer containing the access flags. If the resource file specifies multiple access flags, their bitmasks are merged in the integer.
This method generates one of the following status codes:
S_OK
. Success.
ERROR_TSS_ABORT
. Abort in progress, probably resulting from a user request.
ERROR_GET_TLS_INDEX
. An internal storage error (unrecoverable) occurred.
ERROR_OUT_OF_MEMORY
. An attempt to allocate dynamic memory failed.
This call parses the resources associated with the script, extracts the datapool access flags, and returns them in a form suitable for passing to TSSDatapool.Open
.
This first example returns the datapool access flags in the resource file to flags
. The second example invokes TSSDatapool.Open
, whose arguments are passed by the LoadResString
(a built-in function) from the resource file.
Dim Flags as Long flags = rtcom.GetDatapoolAccessFlags tssPool.Open LoadResString(TSSRES_datapoolname), _ rtCOM.GetDatapoolAccessFlags, _ rtCOM.GetDatapoolOverrideList
Gets datapool override column name/values from the resource file.
GetDatapoolOverrideList() as Variant
A two-dimensional array of name/value pairs containing the datapool override list.
This method generates one of the following status codes:
S_OK
. Success.
ERROR_TSS_ABORT
. Abort in progress, probably resulting from a user request.
ERROR_GET_TLS_INDEX
. An internal storage error (unrecoverable) occurred.
ERROR_OUT_OF_MEMORY
. An attempt to allocate dynamic memory failed.
This call parses the resources associated with the script, extracts any datapool override name/value pairs, and returns them in a form suitable for passing to TSSDatapool.Open
.
This example invokes TSSDatapool.Open
, whose arguments are passed by the LoadResString
(a built-in function) from the resource file.
tssPool.Open LoadResString(TSSRES_datapoolname), _ rtCOM.GetDatapoolAccessFlags, _ rtCOM.GetDatapoolOverrideList
Controls object monitoring and reporting.
Monitor
(toggle
As String, [class
As Variant], [method
As Variant], [instance
As Variant])
This method generates one of the following status codes:
By default, the COMinterception mechanism monitors all non-TSS objects in order to keep track of them. This call allows you to exclude objects that should not be monitored. You can specify an object to exclude/include by specifying its class, method, instance, or a combination.
This example excludes from monitoring all methods and instances of the class ADODB
.
rtcom.Monitor "OFF", "ADODB"
Sets the command ID for a COM method call.
SetCMDID
(cid
As String)
This method generates one of the following status codes:
Command IDs appear in logs in order to improve their readability.
This example sets the command ID for a method call to test001
.
rtcom.SetCMDID "test001"
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 |