Test Script Services Reference |
Use the measurement methods to set timers and environment variables and to get the value of internal variables. Timers allow you to gauge how much time is required to complete specific activities under varying load conditions. Environment variables allow for the setting and passing of information to virtual testers during script playback. Internal variables store information used by the TestManager to initialize and reset virtual tester parameters during script playback.
Commonly used with TestManager.
The following table lists the measurement methods. They are methods of class TSSMeasure
.
CommandEnd
Logs an end-command event.
CommandStart
Logs a start-command event.
EnvironmentOp
Sets an environment variable.
GetTime
Gets the elapsed time of a run.
InternalVarGet
Gets the value of an internal variable.
Think
Sets a think-time delay.
TimerStart
Marks the start of a block of actions to be timed.
TimerStop
Marks the end of a block of timed actions.
Marks the end of a timed command.
CommandEnd
([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 command name and label entered with CommandStart
are logged, and the run state is restored to the value that existed before the 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 can 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 marks the end of the timed activity specified by the previous CommandStart
call.
Dim measure As TSSMeasure
measure.CommandEnd
TSS_LOG_RESULT_PASS, "Command timer failed", 0, 0,
"Login command completed", NULL
CommandStart, TSSAdvanced.LogCommand
CommandStart
(label
As String,name
As String,state
As Long)
label
The name of the timer to be started and logged, or
NULL
for an unlabeled timer.
name
The name of the command to time.
state
The run state to log with the timed command. See the run state table. You can enter 0 (
MST_UNDEF
) if you're uninterested in the run state.
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.
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.
A command is a user-defined name appearing in the log of a test run. By placing CommandStart
and CommandEnd
calls around a block of lines in a script, you can log the time required to complete the actions in the block.
During script playback, TestManager displays progress for different virtual testers. What is displayed for a group of actions associated by CommandStart
depends on the run state argument. Run states are listed in the run state table.
CommandStart
increments IV_cmdcnt
, sets the name, label, and run state for TestManager, and sets the beginning time stamp for the log entry. CommandEnd
restores the TestManager run state to the run state that was in effect immediately before CommandStart
.
This example starts timing the period associated with the string Login
.
Dim measure As TSSMeasure
measure.CommandStart
"initTimer", "Login", MST_WAITRESP
CommandEnd
, TSSAdvanced.LogCommand
Sets a virtual tester environment variable.
EnvironmemtOp
(envVar
As EvarKey,envOp
As EvarOp,envVal
As Variant)
envVar
The environment variable to operate on. See Arguments of TSSMeasure.EnvironmentOpfor a list and description of environment variable constants.
envOp
The operation to perform. See Arguments of TSSMeasure.EnvironmentOp for a list and description of the operation constants..
envVal
The value operated on as specified by
envOp
to produce the new value for envVar
.
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_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.
Environment variables define and control the environment of virtual testers. Using environment variables allows you to test different assumptions or runtime scenarios without re-writing your test scripts. For example, you can use environment variables to specify:
See Arguments of TSSMeasure.EnvironmentOp for a list and description of the values that can be used for argument envVar
.
Environment control options allow a script to control a virtual tester's environment by operating on the environment variables. Every environment variable has, instead of a single value, a group of values: a default value, a saved value, and a current value.
See the EnvironmentOP table for the values that can be used for argument envOp
.
This example gets the current value of EVAR_Think_dist
. .
Dim measure As New TESTSERVICESLib.TSSMeasure
Varient cur_dist
measure.EnvironmentOp
EVAR_Think_dist, EVAR_eval, cur_dist
Gets the elapsed time since the beginning of a suite run.
GetTime()
As Long
On success, this method returns the number of milliseconds elapsed in a suite run.
This method may generate one of the followingerror codes:
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.
For execution within TestManager, this call retrieves the time elapsed since the start time shared by all virtual testers in all test scripts in a suite.
For a test script executed outside TestManager, the time returned is the milliseconds elapsed since the call to TSSSession.Connect
, or since the value of CTXT_timeZero
set by TSSSession.Context
.
This example stores the elapsed time in etime
.
Dim etime As Long
Dim measure As New TSSMeasure
etime = measure.GetTime
Gets the value of an internal variable.
InternalVarGet
(internVar
As IVKey,ivVal
As Variant)
internVar
The internal variable to operate on. See Arguments of TSSMeasure.InternalVarGet for a list and description of the internal variable constants..
ivVal
OUTPUT. The returned value of the specified
internVar
.
This method may generate one of the followingerror codes:
ERROR_OUT_OF_MEMORY
. An attempt to allocate dynamic memory failed.
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.
Internal variables contain detailed information that is logged during script playback and used for performance analysis reporting. This function allows you to customize logging and reporting detail.
This example stores the current value of the IV_error
internal variable in IVVal
.
Dim measure As New TSSMeasure
measure.InternalVarGet
IV_error,IVVal
Puts a time delay in a script that emulates a pause for thinking.
Think
([thinkAverage
As Long])
This method may generate one of the followingerror codes:
ERROR_INVALID_PARM
. A required argument is missing or invalid.
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.
A think-time delay is a pause inserted in a performance test script in order to emulate the behavior of actual application users.
For a description of environment variables, see EnvironmentOp
on page50.
This example calculates a pause based on the value stored in the environment variable EVAR_Think_avg and inserts the pause into the script.
Dim measure As New TSSMeasure
measure.Think
Marks the start of a block of actions to be timed.
TimerStart ([label
As String], [timeStamp
As Long])
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.
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.
This call associates a starting time stamp with label
for later reference by TimerStop
. The TestManager reporting system uses captured timing information for performance analysis reports.
Starting an unlabeled timer sets a start time for an event that you want to subdivide into timed intervals. See the example for TimerStop
. You can get a similar result using named timers, but there will be a slight difference in the timing calculation due to the overhead of starting a timer.
This example times actions designated event1
, logging the current time.
Dim measure As New TSSMeasure
measure.TimerStart
"event1"
\xd4 action to be timed
measure.TimerStop "event1"
Marks the end of a block of timed actions.
TimerStop (label
As String, [timeStamp
As Long], [rmFlag
As Long])
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.
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.
Normally, this call associates an ending time stamp with a label specified with TimerStart
. If the specifiedlabel
was not set by a previous TimerStart
but an unlabeled timer exists, this call logs an event using the specified label and the start time specified for the unlabeled timer with TimerStart
. If rmFlag
is specified as 0, multiple invocations of TimerStop
are allowed against a single TimerStart
. This usage (see the example) allows you to subdivide a timed event into separate timed intervals.
This example stops an unlabeled timer without removing it. In the log, event1
and event2
will record the time elapsed since the TimerStart call.
Dim measure As New TSSMeasure measure.TimerStart() \xd4 action to be timed measure.TimerStop
"event1" \xd4 another action to be timed measure.TimerStop
"event2"
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 |