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 static 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.
voidinternalVarSetInt
(intinternVar
, intiVal
) voidinternalVarSetString
(intinternVar
, StringBuffersVal
)
internVar
The internal variable to operate on. Internal variables and their values are listed in the tables starting on page254.
iVal
The new integer value for
internVar
. For the implementation of this argument's data type, see TSSInteger.
sVal
The new string internal value for
internVar
.
These methods may throw an exception with one of the following values:
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 exceptions and do not log it, TestManager is not aware of the exception 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.
TSSAdvanced.internalVarSetInt
(IV_cmdcnt,0);
voidlogCommand
(Stringname
, Stringlabel
, shortresult
, Stringdescription
, intstarttime
, intendtime
, Stringlogdata
, TSSNamedValue []property
) voidlogCommand
(Stringname
, Stringlabel,
shortresult
)
name
The command name.
label
The event label.
result
Specifies the notification preference regarding the result of the call. Can be one of the following:
TSS_LOG_RESULT_NONE
(default: no notification)
TSS_LOG_RESULT_PASS
TSS_LOG_RESULT_FAIL
TSS_LOG_RESULT_WARN
TSS_LOG_RESULT_STOPPED
TSS_LOG_RESULT_INFO
TSS_LOG_RESULT_COMPLETED
TSS_LOG_RESULT_UNEVALUATED
0
specifies the default.
description
Contains the string to be displayed in the event of failure.
starttime
An integer indicating a time stamp. If specified as 0, the logged time stamp is the later of the values contained in internal variables
IV_fcs_ts
and IV_fcr_ts
.
endtime
An integer indicating a time stamp. If specified as 0, the time set by
commandEnd()
is logged.
logdata
Text to be logged describing the ended command.
property
An array containing property name/value pairs, where
property[n].name
is the property name and property[n].value
is its value. For the implementation of this argument's data type, see TSSNamedValue.
These methods may throw an exception with one of the following values:
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 exceptions and do not log it, TestManager is not aware of the exception 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.
This example logs a message for a login script.
TSSAdvanced.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.
intthinkTime
(intthinkAverage
) intthinkTime
()
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, these methods return a calculated think-time average.
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`
int iv = TSSMeasure.getTime();
TSSAdvanced.internalVarSetInt(IV_fcs_ts, iv);
TSSAdvanced.internalVarSetInt(IV_lcs_ts, iv);
TSSAdvanced.internalVarSetInt(IV_fcr_ts, iv);
TSSAdvanced.internalVarSetInt(IV_lcr_ts, iv);
int pause = TSSAdvanced.thinkTime
(5000);
Rational Test Script Services for Java | Rational Software Corporation |
Copyright (c) 2003, Rational Software Corporation | http://www.rational.com support@rational.com info@rational.com |