Monday, January 21, 2013

Script to Run Multiple test sets in Test Lab of QC via QTP

Vb Script to Run MultipleTest Sets in Test Lab of Quality Center via QTP

'All the test sets should reside inside single parent folder

''To execute the this file enter the below line into commond prompt
     'C:\Windows\SysWOW64\cscript.exe "C:\Path of this file.vbs"

Dim aSet_name
Dim iCount
Dim QCConnection
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
'---------------------------------------------------------------------------------------------------------------

QCConnection.InitConnectionEx "http://server address/qcbin"  '<--------------- Fill in server address
     
QCConnection.login "Username ", "Password"   '<---------------- QC Username and Password

QCConnection.Connect "QC Domain", "Qc Project"   '<---------------- FILL Domain/Project
nPath ="Root\Test1\Path"               '<----------------Parent Path 
aSet_name=array("TestSet1","TestSet2","TestSetn")   '<-------Test Set names
'-----------------------------------------------------------------------------------------------------------------

Set TSetFact = QCConnection.TestSetFactory
Set tsTreeMgr = QCConnection.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath(nPath)

If tsFolder Is Nothing Then
 'msgbox "error"
 wscript.echo "error"
 Call QC_Disconnect()
End If

for iCount=0 to ubound(aSet_name)
 Set tsList = tsFolder.FindTestSets( aSet_name(iCount) )

 If tsList.Count > 1 Then

  'MsgBox "FindTestSets found more than one test set: refine search"
  wscript.echo "FindTestSets found more than one test set: refine search"

 ElseIf tsList.Count <> 1 then
  'MsgBox "FindTestSets: test set not found"
  wscript.echo  "FindTestSets: test set not found"
 else
        'End If

  Set theTestSet = tsList.Item(1)
  Set Scheduler = theTestSet.StartExecution("")
  Scheduler.RunAllLocally = True
  Scheduler.HostTimeOut = 100000  'The time to wait for response before  failing.
  Scheduler.run
  Set execStatus = Scheduler.ExecutionStatus
  RunFinished = False

  while RunFinished = False
   execStatus.RefreshExecStatusInfo "all", True
   RunFinished = execStatus.Finished
  wend

  wscript.echo "Completed Execution of Test Set "&aSet_name(iCount)
 end if
next


Call QC_Disconnect()
'-----------------------------------------------------
Function QC_Disconnect()
 QCConnection.Disconnect
 QCConnection.Logout
 Set QCConnection = Nothing
End Function

1 comment:

  1. Hi,
    Multiple Test Set are executing but in each Test Set only one Test is executing.

    Any one tried to execute multiple Test in each Test Set.

    ReplyDelete