标签:
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 not found then exit.
If not isFound Then
Reporter.ReportEvent micFail,"Mark status in ALM", "TestSet "& QCTestSetName & " was 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 this to ensure all tests have ‘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
标签:
原文地址:http://www.cnblogs.com/ellie-test/p/4353797.html