Working with Test Scripts |
You can run test scripts either from within or outside of TestManager. Test scripts that you execute from within TestManager can run on the local host or on an agent host.
Where you run a test script depends, in part, upon your reason for running it:
Performance tests are typically run within TestManager. Component tests conducted with QualityArchitect can be run either from within TestManager or Visual Basic.
A TestManager suite is a collection of test scripts. In TestManager, you typically run tests by running a single script or a number of scripts in a suite.
You can combine scripts of different types in the same suite -- for example, you can add your Visual Basic scripts to a suite that also contains Java, GUI, and VU scripts, and even scripts of a custom test type.
For information about adding scripts to a TestManager suite, see Rational TestManager User's Guide.
A .cls test script that you want to run inside a suite must extend the TestScript class and implement the ITestInterface_TestMain
method. This method is the entry point for the class.
The following is an example of the method declaration:
Public Function ITestinterface_TestMain( Optional ByVal args As Variant) As Variant
How you run a test script from your IDE depends on whether you are using QualityArchitect.
If a QualityArchitect test script that you want to run from Visual Basic meets the requirements described below, you can run it by clicking Run > Start.
Main
entry point, and Main
must include a call to ITestInterface_TestMain
in a .cls file. A sample .bas file is shown below.
Option Explicit
Sub Main()
On Error GoTo OnMainError
Dim retval As Variant
Dim objMoveMoneyPerform As ITestInterface
Set objMoveMoneyPerform = New Perform
\qInvoke the TestMain method
retval = objMoveMoneyPerform.TestMain(Command())
Exit Sub
OnMainError:
\qTODO: uncomment below to implement error handling.
\qDebug.Print ("Following error Occurred in " + Err.Source + ":"
+ Err.Description)
\qMsgBox ("Following error Occurred in " + Err.Source + ":" +
Err.Description)
End Sub
ITestInterface_TestMain
must be preceded by calls to LoginToTestRepository
and StartTestServices
, and concluded by a call to EndTestServices
. (These are methods of the TMSConnector
class.) A sample .cls file is shown below. As shown, the argument to StartTestServices
is a string parameter specifying the path of the test script relative to the test script source directory.
Implements ITestInterface Option Explicit \qLocal variablesPrivate tms As TMSConnector
\qTMS Connector Object.
Private Log As TestLog \qTestLog Object. \qClass Instance Intialize code. Private Sub Class_Initialize() \qCreate the private member objects.Set tms = New TMSConnector
Set Log = New TestLog End Sub \qClass Instance Terminate code. Private Sub Class_Terminate() \qFree the private member objects.Set tms = Nothing
Set Log = Nothing End Sub \qTestScript.TestMain Function( ByVal Args As Variant ) As Variant \qThis method is the method test implementation. The Interface is \qdefined to accept and return a Variant for flexiblity and \qconvenience; there is no special processing or meaning for either \qthe Input parameters or the return value. Public Function ITestInterface_TestMain(Optional ByVal args As Variant) As Variant On Error GoTo OnTestMainError \qInitialize test data store and log servicestms.LoginToTestRepository
tms.StartTestServices "unittests\COM\RQACOMSample Ver 1.0 (Rational QualityArchitect Sample for COM)\MoveMoneyPerform"
\qTest Code goes here OnTestMainError: \qIf an error occurred, log it. If Err.Number <> 0 Then Dim Message As String Message = "Unexpected error" & "," & " " & CStr(Err.Number) & " was raised." Log.Message Message, TSS_LOG_RESULT_FAIL, Err.Description End If \qShutdown test data store and log servicestms.EndTestServices
End Function
To run a test script from your IDE when QualityArchitect is not involved, do the following:
C:\Program Files\Rational\Rational Test\rttsee.exe -e rttseavb ScriptName
In the example, ScriptName is the name of your Visual Basic test script.
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 |