Test Script Services Reference |
You can use the advanced methods to perform timing calculations, logging operations, and internal variable initialization functions. TestManager performs these operations on behalf of scripts in a safe and efficient manner. Consequently, the functions need not and usually should not be performed by individual test scripts.
Commonly used with TestManager.
The following table lists the advanced methods. They are methods of class TSSAdvanced
.
InternalVarSet
Sets the value of an internal variable.
LogCommand
Logs a command event.
ThinkTime
Calculates a think-time average.
Sets the value of an internal variable.
InternalVarSet
(internVar
As IVKey,ivVal
As Variant)
internVar
The internal variable to operate on. Internal variables and their values are listed in the table starting on page178.
ivVal
The new value for
internVar
.
This method maygenerate one of the following error codes:
ERROR_CONVERT_BSTR
. An encountered string cannot be converted.
ERROR_INVALID_PARM
. A required argument is missing or invalid.
TSS_NOSERVER
. No previous successful call to TSSSession.Connect
.
TSS_INVALID
. The timer label is invalid, or there is no unlabeled timer to stop.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
If you handle one of these errors and do not log it, TestManager is not aware of the error and does not log a Fail result for it. The script continues to run, and TestManager could log a Pass result for the script.
The values of some internal variables affect think-time calculations and the contents of log events. Setting a value incorrectly could cause serious misbehavior in a script.
This example sets IV_cmdcnt
to 0.
Dim advanced TSSAdvanced
advanced.InternalVarSet
IV_cmdcnt,0
LogCommand
(name
As String,label
As String, [result
As Integer], [description
As String], [starttime
As Long], [endtime
As Long], [logdata
As String], [property
[] As NamedValue])
This method may generate one of the followingerror codes:
ERROR_CONVERT_BSTR
. An encountered string cannot be converted.
ERROR_INVALID_PARM
. A required argument is missing or invalid.
ERROR_OUT_OF_MEMORY
. An attempt to allocate dynamic memory failed.
TSS_NOSERVER
. No previous successful call to TSSSession.Connect
.
TSS_ABORT
. Pending abort resulting from a user request to stop a suite run.
If you handle one of these errors and do not log it, TestManager is not aware of the error and does not log a Fail result for it. The script continues to run, and TestManager could log a Pass result for the script.
The value of IV_cmdcnt
is logged with the event.
The command name and label entered with TSSMeasure.
CommandStart are logged, and the run state is restored to the value that existed prior to the TSSMeasure.
CommandStart call.
An event and any data associated with it are logged only if the specified result
preference matches associated settings in the EVAR_LogData_control
or EVAR_LogEvent_control
environment variables. (See Arguments of TSSMeasure.EnvironmentOp.) Alternatively, the logging preference may be set with the EVAR_Log_level
and EVAR_Record_level
environment variables. The TSS_LOG_RESULT_STOPPED, TSS_LOG_RESULT_COMPLETED, and TSS_LOG_RESULT_UNEVALUATED preferences are intended for internal use.
NamedValue is a dimensioned array of name/value pairs. For example, an array of 10 name/value pairs could be implemented as follows:
Dim NV(9,1) As String NV(0,0)= "name1" NV(0,1)= "value1" NV(1,0)= "name2" NV(1,1)= "value2" ...
This example logs a message for a login script.
Dim advanced As TSSAdvanced
advanced.LogCommand
"Login", "initTimer", TSS_LOG_RESULT_PASS,
"Command timer failed", 0, 0, "Login command completed", NULL
TSSMeasure.
CommandStart, TSSMeasure.
CommandEnd
Calculates a think-time average.
ThinkTime
([thinkAverage
As Long]) As Long
thinkAverage
If specified as 0, the number of milliseconds stored in the
ThinkAvg
environment variable is entered. Otherwise, the value specified overrides ThinkAvg
.
On success, this method returns a calculated think-time average. A negative exit value indicates an error. Call for more information
This method may generate the following error code.
This call calculates and returns a think time using the same algorithm as TSSMeasure.Think. But unlike TSSMeasure.Think, this call inserts no pause into a script.
This function could be useful in a situation where a test script calls another program that, as a matter of policy, does not allow a calling program to set a delay in execution. In this case, the called program would use TSSMeasure.ThinkTime to recalculate the delay requested by TSSMeasure.Think before deciding whether to honor the request.
This example calculates a pause based on a think-time average of 5000 milliseconds.
ctime = `tsscmd GetTime`
Dim pause, iv As Long
Dim advanced As New TSSAdvanced
Dim measure As New TSSMeasure
iv = measure.GetTime
advanced.InternalVarSet IV_fcs_ts, iv
advanced.InternalVarSet IV_lcs_ts, iv
advanced.InternalVarSet IV_fcr_ts, iv
advanced.InternalVarSet IV_lcr_ts, iv
pause = advanced.ThinkTime
(5000)
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 |