OptionExplicit 'These variables are required by the interface:
Private Status AsString' The current testing status Private Descr AsString' The current testing description ' Connection Parameters Private ServerName AsString' The server URL Private ProjectName AsString' The current project’s name Private DomainName AsString' The Quality Center domain name Private UserName AsString' The current user name Private SysUserName AsString' The workstation system user Private Password AsString' The current user’s password ' Current Test Private TestPath AsString' The current test’s path Private TestName AsString' The current test’s name Private TestID AsInteger' The current test’s ID ' Current Test Set Private TestSetID AsString' The current test set’s ID Private TestSetInfo AsString' The current test set’s info ' Current Test Instance Private TestInstID AsLong' The test instance's ID Private TestInstName AsString' The test instance's name Private TestInstDescr AsString' The test instance's descriptor
Private S_OK AsLong' Return value if the run is OK Private S_FALSE AsLong' Return value if the run failed Private END_OF_TEST AsLong' Return value for end of test
' Quality Center calls this method to check if the ' host is ready. ' You can use this sub-routine to initialize the return value variables. ' In this example, is_host_ready always reports that ' the host is ready, and changes the description to ' "Ready"
Descr = "Ready"
is_host_ready = S_OK
EndFunction
PublicFunction set_value(ByVal name AsString, _ ByVal Value AsString) AsLong
'Quality Center uses this method to set the 'variables declared.
SelectCase name ' Connection Parameters Case"TDAPI_host_name" ServerName = Value Case"project_name" ProjectName = Value Case"domain_name" DomainName = Value Case"user_name" UserName = Value Case"sys_user_name" SysUserName = Value Case"password" Password = Value ' Current Test Case"test_path" TestPath = Value Case"test_name" TestName = Value Case"test_id" TestID = Val(Value) ' Current Test Set Case"test_set_id" TestSetID = Val(Value) Case"test_set" TestSetInfo = Value ' Current Test Instance Case"testcycle_id_integer" TestInstID = Val(Value) Case"tstest_name" TestInstName = Value Case"tstest_name" TestInstDescr = Value EndSelect
set_value = S_OK
OnErrorResumeNext
Log "set_value: " _ & " name = " & name & ", value = " & Value
' Quality Center calls this method to check the ' status and description of the run.
StatusDescription = Descr
CurrentStatus = Status
get_status = S_OK
EndFunction
PublicFunction run() AsLong
' Quality Center calls this method to run the test ' and update the test status and description. ' In this example, batch.bat is downloaded ' and run.
OnErrorGoTo runErr
Log "Start run " & CStr(Now)
Dim td AsNew TDAPIOLELib.TDConnection Dim TestSetFact As TestSetFactory Dim thisTestSet As TestSet Dim TSTestFact As TSTestFactory Dim thisTSTest As TSTest Dim RunFact As RunFactory Dim theRun As TDAPIOLELib.run
'These variables are needed to get ' batch.bat for this example: Dim TestFact As TDAPIOLELib.TestFactory Dim theTest As TDAPIOLELib.Test Dim LocalScriptPath AsString Dim ExtStorage As TDAPIOLELib.ExtendedStorage
'Connect to the project td.InitConnectionEx ServerName td.ConnectProjectEx DomainName, ProjectName, UserName, Password
'Get a local copy of batch.bat
Set TestSetFact = td.TestSetFactory Set thisTestSet = TestSetFact(TestSetID) Set TSTestFact = thisTestSet.TSTestFactory
Log "TSTestFactory acquired"
'Get the TSTest object Set thisTSTest = TSTestFact(TestInstID)
Log "TSTest ID = " & thisTSTest.ID
'Get the correct version of the test from the TSTest Set theTest = thisTSTest.Test
Log "The test name = " & theTest.name
' Get the file Set ExtStorage = theTest.ExtendedStorage LocalScriptPath = ExtStorage.Load("-r batch.bat", True)
' Add the file name to the path returned from Load ' so it directly refers to the file. LocalScriptPath = LocalScriptPath & "\batch.bat" Log "LocalScriptPath = " & LocalScriptPath
' Update the status variables for use in get_status Status = "RUNNING" Descr = "Running..."
Log "Running..."
' Run the application and update the status Dim rc rc = Shell(LocalScriptPath) Status = "END_OF_TEST" Descr = "Completed"
Log "Command executed"
' Record the run in the project ' Get the run factory for the TSTest Set RunFact = thisTSTest.RunFactory
Log "RunFactory acquired"
'Test run name (ID) Dim runName AsString runName = "New Run"
' Create the new Run Set theRun = RunFact.AddItem(runName)
'User who ran the test (from set_value) theRun("RN_TESTER_NAME") = UserName
Log "Created new Run"
' Mark the run Passed theRun.Status = "Passed" theRun.Post