Test Script Services Reference

prevnext

Logging Class


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.


Applicability

Commonly used with TestManager and QualityArchitect.


Summary

Use the methods listed in the following table to write to the TestManager log. They are static methods of class TSSLog.

Method Description
event() Logs an event.
message() Logs a message event.
testCaseResult() Logs a test case event.


TSSLog.event()

Logs an event.


Syntax

void event (String eventType,  short result, String 
description, TSSNamedValue[] property)
void event (String eventType,  short result)

Element Description
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.


Exceptions

These methods may throw an exception with one of the following values:

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.


Comments

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.


Example

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);

TSSLog.message()

Logs a message.


Syntax

void message(String message,  short result, String description)
void message(String message)

Element Description
message Specifies the string to log.
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 Specifies the string to be put in the entry's failure description field.


Exceptions

These methods may throw an exception with one of the following values:

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.


Comments

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.


Example

This example logs the following message: --Beginning of timed block T1--.

TSSLog.message ("--Beginning of timed block T1--");

TSSLog.testCaseResult()

Logs a test case result.


Syntax

void testCaseResult (String testcase, short result, String 
description, TSSNamedValue[] property)
void testCaseResult (String testcase, short result)

Element Description
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.


Exceptions

These methods may throw an exception with one of the following values:

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.


Comments

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.


Example

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);

prevnext


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