Function Markcasestatusinalm (Qcserver,qcusername, Qcpassword, Qcdomain, Qcproject, Qctestsetpath, QCTestSetName)
Dim Blnconnect
Set tdconnection = CreateObject ("Tdapiole80.tdconnection")
With Tdconnection
' Create a connection with the QC Server
. Initconnectionex Qcserver
' Login to QC
. Login Qcusername, Qcpassword
' Connect to QC Project
. Connect Qcdomain, Qcproject
End with
Set Tstreemanager = Tdconnection.testsettreemanager
' Return the test set tree node from the specified tree path
Set TSFolder = Tstreemanager.nodebypath (Qctestsetpath)
' Returns the list of test sets contained in the folder that match the specified pattern.
Set tslist = tsfolder.findtestsets (qctestsetname)
If tslist.count = 0 Then
Reporter.reportevent Micfail, "Mark status in ALM", "No Testset in the." & Qctestsetpath
Markcasestatusonalm = False
Else
Isfound = False
For each testset in Tslist
If LCase (testset.name) = LCase (Qctestsetname) Then
Isfound = True
Exit for
End If
Next
' If Qctestsetname was wasn't found then exit.
If not Isfound Then
Reporter.reportevent Micfail, "Mark status in ALM", "Testset" & Qctestsetname & "is not found."
Else
' This enables database to update immediately when the field value changes
Testset.autopost = True
' Tstestfactory manages test instances (Tstest objects) in a test set
Set tstestfactory = testset.tstestfactory
' Tstestfactory.newlist (") creates a list of objects according to the specified filter
For each qttest in Tstestfactory.newlist ("")
' Change Test status to N/a
' We do the ' Ensure all tests has ' not run ' before starting execution
' If the execution errors out, we can keep track of the tests that were not run
Qttest.field ("tc_status") = "N/a"
Qttest.post
Next
For each qttest in Tstestfactory.newlist ("")
' Runfactory manages Run instances
Set runfactory = qttest.runfactory
' Add A new new Run instance.
Runname = Runfactory.uniquerunname
Runfactory.additem (Runname)
Set runlist = Runfactory.newlist ("")
For each RN in Runlist
If Rn.name = Runname Then
Set stepfactory = rn. Stepfactory
Set TST = qttest.test
Set DESSTEPF = TST. Designstepfactory
Set dslist = Desstepf.newlist ("")
For each DS in Dslist
Set stp = Stepfactory.additem (Null)
Stp. Field ("St_step_name") =ds. Stepname
Stp. Field ("st_status") = "Passed"
Stp. Field ("st_description") = ds. Stepdescription
Stp. Post
Next
Rn. Status = "Passed"
Rn. Post
End If
Next
Next
Tdconnection.disconnectproject
Tdconnection.releaseconnection
Set tdconnection = Nothing
End Function
Code for QTP and ALM