08-10-2009, 12:13 PM
Hi basanth,
I need to programatically initiate QC execution.I need to connect to QC. Then execute a testset on a particular remote Host machine.
I tried the below code. But it is not working.
Option Explicit
Please let me know how to do this.
Thanks,
Pallavi
I need to programatically initiate QC execution.I need to connect to QC. Then execute a testset on a particular remote Host machine.
I tried the below code. But it is not working.
Option Explicit
Code:
Public Sub RunTestSet(otdc, tsFolderName, tSetName, HostName, runWhere)
Dim TSetFact, tsList
Dim theTestSet
Dim tsTreeMgr
Dim tsFolder
Dim Scheduler
Dim nPath
Dim execStatus
' Get the test set tree manager from the test set factory
'tdc is the global TDConnection object.
Set TSetFact = otdc.TestSetFactory
Set tsTreeMgr = otdc.TestSetTreeManager
' Get the test set folder passed as an argument to the example code
'subject\functionality\SUB FOLDER NAME"
'nPath = "Root\" & Trim(tsFolderName)
nPath = "Root\"& Trim(tsFolderName)
Set tsFolder = tsTreeMgr.NodeByPath(nPath)
If tsFolder Is Nothing Then
err.Raise vbObjectError + 1,"RunTestSet", "Could not find folder" & nPath
End If
'Search for the test set passed as an argument to the example code
Set tsList = tsFolder.FindTestSets(tSetName)
If tsList Is Nothing Then
err.Raise vbObjectError + 1, "RunTestSet", "Could not find test set in the " & nPath
End If
If tsList.Count > 1 Then
MsgBox "FindTestSets found more than one test set: refine search"
Exit Sub
ElseIf tsList.Count < 1 Then
MsgBox "FindTestSets: test set not found"
Exit Sub
End If
Set theTestSet = tsList.Item(1)
'Debug.Print theTestSet.ID
'Start the scheduler on the local machine
Set Scheduler = theTestSet.StartExecution(HostName)
'Set up for the run depending on where the test instances
' are to execute.
Select Case runWhere
Case "RUN_LOCAL"
'Run all tests on the local machine
Scheduler.RunAllLocally = True
Case "RUN_REMOTE"
'Run tests on a specified remote machine
Scheduler.TdHostName = HostName
' RunAllLocally must not be set for
' remote invocation of tests.
' Do not do this:
' Scheduler.RunAllLocally = False
Case "RUN_PLANNED_HOST"
'Run on the hosts as planned in the test set
Dim TSTestFact, TestList
Dim tsFilter
Dim TSTst
'Get the test instances from the test set
Set TSTestFact = TestSet.TSTestFactory
Set tsFilter = TSTestFact.Filter
tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
Set TestList = TSTestFact.NewList(tsFilter.Text)
Scheduler.RunAllLocally = False
End Select
'Run the tests
Scheduler.run
Set execStatus = Scheduler.ExecutionStatus
' While (RunFinished = False)
' execStatus.RefreshExecStatusInfo "all", True
' RunFinished = execStatus.Finished
' Wend
End Sub
'================================
Const qcHostName = "mendelbrot:8080"
Const qcDomain = "HOSP"
Const qcProject = "QC_Test" 'Please define here the name of the project
Const qcUser = "bheemanagoud" 'Please define here the username
Const qcPassword = "manasa556$" '‘Please define here the password
Dim tdc
Dim qcServer
Dim objArgs
Dim strArg
Dim strTestSet
Dim bRunCode
'======GETTING ARGUMENTS============== pxb
set objArgs = WScript.Arguments
If WScript.Arguments.Count<1 Or WScript.Arguments.Count>2 Then
WScript.Echo "Please enter the name of the test set"
bRunCode = False
Else
For Each strArg in objArgs
WScript.Echo strArg& "is starting…"
strTestSet = strArg
bRunCode = True
Next
End If
'===========================================================
qcServer = "http://" & qcHostName
qcServer = qcServer & "/qcbin"
Set tdc = CreateObject("TDAPIOLE80.tdconnection")
If (tdc Is Nothing) Then
MsgBox "tdc object is empty"
End If
tdc.InitConnectionEx qcServer
tdc.Login qcUser, qcPassword
tdc.Connect qcDomain, qcProject
'RunTestSet tdc,"Insert here path to the test set", strTestSet , "nsert here the name of the machine", "RUN_LOCAL"
RunTestSet tdc,"trial1", "deleted" , "TA-Q5", "RUN_REMOTE"
'Disconnect from the project
If tdc.Connected Then
tdc.Disconnect
End If
'Log off the server
If tdc.LoggedIn Then
tdc.Logout
End If
'Release the TDConnection object.
tdc.ReleaseConnection
'Check status (For illustrative purposes.)
Set tdc = Nothing
Please let me know how to do this.
Thanks,
Pallavi