Extended Test Script Services Reference |
This class lets you log information from test scripts and stubs.
The items in this class are members of RTCOMVPLib.TestLog
.
Commonly used with QualityArchitect.
QualityArchitect is required for use of this class.
The following example logs a number of status messages about the various stages of a datapool operation.
Function ITestInterface_TestMain(ByVal args As Variant) As Variant On Error GoTo MoveMoneyPerformScript_OnTestMainError 'Declare variables. Dim lPrimeAccount As Long Dim lSecondAccount As Long Dim lAmount As Long Dim lTranType As Long Dim actRet As String Dim expRet As String Dim dp As New TSSDataPool Dim expErr As Variant Dim NumRows As Integer Dim Desc As String Dim Message As String 'Set default values NumRows = 0 'Initialize test data store and log services tms.LoginToTestRepository tms.StartTestServices "unittests\COM\RQACOMSample Ver 1.0 (Rational QualityArchitect Sample for COM)\MoveMoneyPerform" 'Create Object Dim obj As Object Set obj = CreateObject("RQACOMSample.MoveMoney") 'Open Datapool dp.Open "_MoveMoney_Perform_D" 'Loop over datapool and perform test. While dp.Fetch 'Keep counter of number of rows fetched. NumRows = NumRows + 1 'Get the column data from the datapool. lPrimeAccount = CLng(dp.Value("lPrimeAccount")) lSecondAccount = CLng(dp.Value("lSecondAccount")) lAmount = CLng(dp.Value("lAmount")) lTranType = CLng(dp.Value("lTranType")) expRet = CStr(dp.Value("expectedReturn")) expErr = dp.Value("expectedError") 'Disable Default Error Handler On Error Resume Next 'Clear the global error object in case it is set to something. Err.Clear 'Call the method under test. actRet = obj.Perform(lPrimeAccount, lSecondAccount, lAmount, lTranType) 'Save the Error info Dim actErr As Long Dim actErrDesc As String actErr = Err.Number actErrDesc = Err.Description 'Enable Default Error Handler On Error GoTo MoveMoneyPerformScript_OnTestMainError 'Evaluate the result of the method call If IsEmpty(expErr) Then If actErr <> 0 Then 'Not expecting an error and one occurred. Desc = "Unexpected error" & "," & " " & CStr(actErr) & " was raised." & vbCrLf & actErrDesc Log.Message
"Unexpected result", TSS_LOG_RESULT_FAIL, Desc Else 'Not expecting an error and none occurred... 'Therefore, check the expected expRet = actRet. If (expRet = actRet) Then Log.Message
"Expected result", TSS_LOG_RESULT_PASS, "Call to Perform returned expected value" Else Log.Message
"Unexpected result", TSS_LOG_RESULT_FAIL, "Call to Perform returned unexpected value, " & actRet & "." End If End If Else 'expErr can represent Err.Number or Err.Description If actErr = expErr Or actErrDesc = expErr Then 'Expecting an Error and the one raised matched 'the expected error. Desc = "Expected error" & "," & " " & expErr & " was raised." Log.Message
"Expected Error", TSS_LOG_RESULT_PASS, Desc Else 'Expecting an Error and either none was raised or... 'the one raised was not the one we expected. Desc = "Expected error" & "," & " " & expErr & " was not raised." Log.Message
"Unexpected error", TSS_LOG_RESULT_FAIL, Desc End If End If Wend If NumRows = 0 Then 'Datapool did not contain any rows. Log a warning. Desc = "Datapool " & """" & "MoveMoneyPerform" & """" & " is empty." Log.Message
"Empty Datapool", TSS_LOG_RESULT_WARN, Desc End If 'Execution to this point indicates success, so clear 'any handled errors that may have occurred and continue. Err.Clear 'Fall through to cleanup. 'No Error will be logged because Err.Number now equals zero. MoveMoneyPerformScript_OnTestMainError: 'If an error occurred, log it. If Err.Number <> 0 Then Message = "Unexpected error" & "," & " " & CStr(Err.Number) & " was raised." Log.Message
Message, TSS_LOG_RESULT_FAIL, Err.Description End If 'Close the datapool If Not dp Is Nothing Then dp.Close Set dp = Nothing End If 'Shutdown test data store and log services tms.EndTestServices End Function
This class contains the following methods:
Note: In addition to these methods, you can also use the methods in the TSSLog
class, as summarized in the section Logging Class.
Message
(message
As String, [result
As Integer], [description
As String])
For examples of this method, see TestLog Example.
Logs an error that occurred during the execution of a test script.
WriteError
(hr
As Long, Description As String)
hr
The error to log.
description
A description of the error.
This method logs a Fail result for the test script.
The description appears in the Description area of the Log Event Properties dialog box.
Logs information about an error that occurred during the execution of a QualityArchitect stub.
WriteStubError
(hr as Long,description
As String)
hr
The error to log.
description
A description of the error.
The description appears in the Description area of the Log Event Properties dialog box.
For an example of this method, see LookUpTable Example.
Logs a message relating to the execution of a QualityArchitect stub, and also includes a description of the message.
WriteStubMessage
(bsMessage
As String,Description
As String)
bsMessage
The message to insert into the log.
Description
A description of the message. The description lets you expand upon the logged message.
The message appears in the Log Event column of the LogViewer. The description appears in the Description field of the Log Event Properties dialog box.
For examples of this method, see LookUpTable Example.
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 |