Every now and again we get a test set that has too many steps or a corrupted step and is not able to be viewed or deleted in the application. We have previously been having our DBA remove these. Is there a way to remove these test sets using API in order to avoid DBA involvement?
Answer by Jafar · Jul 15, 2016 at 09:16 PM
You can delete test sets from the API using the TestSet Factory Object and the RemoveItem method. Below is an example:
On Error Resume Next Dim qcServer, qcDomain, qcProject, qcUser, qcPassword 'Define variable values for QC connection qcServer = "http://qc:8080/qcbin/" qcDomain = "DEFAULT" qcProject = "ALM_DEMO" qcUser = "alex_alm" qcPassword = "" 'Create the TD Connection object Set tdc = CreateObject("tdapiole80.tdconnection") 'Establish the connection and log in to the project tdc.InitConnectionEx qcServer tdc.Login qcUser, qcPassword tdc.Connect qcDomain, qcProject 'If connection is established If tdc.Connected = True Then 'Get the TestSetFactory object Set TSFact = tdc.TestSetFactory 'Remove the TestSet by ID TSFact.RemoveItem(30) 'Report any errors If Err.Number <> 0 Then MsgBox Err.Number & " : " & Err.Description End If 'Kill the TestSetFactory object Set TSFact = Nothing End If 'Disconnect from the project and logout of QC tdc.Disconnect tdc.Logout 'Kill the TDConnection object Set tdc = Nothing On Error Goto 0