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

Event (eventType As String, [result As Integer], [description 
As String], [property[] As NamedValue])

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.


Error Codes

This method may generate one of the followingerror codes:

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.


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.

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"
...

Example

This example logs the beginning of an event of type Login Dialog.

Dim scriptProp (1,1) As String
scriptProp(0,0)= "ScriptName"
scriptProp(0,1)= "Login"
scriptProp(1,0)= "LineNumber"
scriptProp(1,1)= "1"
Dim log As New TSSLog
log.Event "Login Dialog",0,"Login script failed",scriptProp

TSSLog.Message

Logs a message.


Syntax

Message (message As String, [result As Integer], [description 
As String])

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.


Error Codes

This method may generate one of the followingerror codes:

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.


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

Dim log As New TSSLog
log.Message "--Beginning of timed block T1--"

TSSLog.TestCaseResult

Logs a test case result.


Syntax

TestCaseResult (testcase As String, [result As Integer], 
[description As String], [property[] As NamedValue])

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.


Error Codes

This method may generate one of the followingerror codes:

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.


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.

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"
...

Example

This example logs the result of a test case named Verify login.

Dim loginResult(0,1) As String
loginResult(0,0)= "Result"
loginResult(0,1)= "OK"
Dim log As New TSSLog
log.TestCaseResult "Verify login",0,NULL,loginResult

prevnext


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