Test Script Services Reference |
Use the logging methods to build the log that TestManager uses for analysis and reporting. You can log events, messages, or test case results.
A logged event is the record of something that happened. Use the environment variable EVAR_LogEvent_control
(Arguments of TSSMeasure.environmentOp()) to control whether or not an event is logged.
An event that gets logged may have associated data (either returned by the server or supplied with the call). Use the environment variable EVAR_LogData_control
(Arguments of TSSMeasure.environmentOp()) to control whether or not any data associated with an event is logged.
Commonly used with TestManager and QualityArchitect.
Use the methods listed in the following table to write to the TestManager log. They are static methods of class TSSLog.
event()
Logs an event.
message()
Logs a message event.
testCaseResult()
Logs a test case event.
voidevent
(StringeventType
, shortresult
, Stringdescription
, TSSNamedValue[]property
) voidevent
(StringeventType
, shortresult
)
eventType
Contains the description to be displayed in the log for this event.
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 put in the entry's failure description field.
property
An array containing property name/value pairs, where
property[n].name
is the property name and property[n].value
is its value. See TSSNamedValue for the implementation of this argument's data type.
These methods may throw an exception with one of the following values:
TSS_NOSERVER
. No previous successful call to TSSSession.connect()
.
TSS_INVALID
. An unknown result
was specified.
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 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.
This example logs the beginning of an event of type Login Dialog
.
TSSNamedValue[] scriptProp = new TSSNamedValue[2];
scriptProp[0] = new TSSNamedValue();
scriptProp[0].name = "ScriptName";
scriptProp[0].value = "Login";
scriptProp[1] = new TSSNamedValue();
scriptProp[1].name = "LineNumber";
scriptProp[1].value = "1";
TSSLog.event
("Login Dialog",0,"Login script failed",scriptProp);
voidmessage
(Stringmessage
, shortresult
, Stringdescription
) voidmessage
(Stringmessage
)
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.
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.
This example logs the following message: --Beginning of timed block T1--
.
TSSLog.message
("--Beginning of timed block T1--");
voidtestCaseResult
(Stringtestcase
, shortresult
, Stringdescription
, TSSNamedValue[]property
) voidtestCaseResult
(Stringtestcase
, shortresult
)
testcase
Identifies the test case whose result is to be logged.
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 a log failure.
property
An array containing property name/value pairs, where
property[n].name
is the property name and property[n].value
is its value. See TSSNamedValue for the implementation of this argument's data type.
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.
A test case is a condition, specified in a list of property name/value pairs, that you are interested in. This method searches for the test case and logs the result of the search.
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 by 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 the result of a test case named Verify login
.
TSSNamedValue[] loginResult = new TssNamedValue[1];
loginResult[0] = new TSSNamedValue();
loginResult[0].name = "Result";
loginResult[0].value = "OK";
TSSLog.testCaseResult
("Verify login",0,null,loginResult);
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 |