0

我在 QC 中进行了大约 800 次奇怪的测试。我有一个 vbscript,它将在我运行脚本时运行并将测试实验室中的所有测试用例标记为 PASS。唯一担心的是,脚本总是从第一个测试开始运行,直到我指定的最后一个测试(比如从第一次测试到第 700 次测试或从第一次测试到第 140 次测试)。我想更改代码,以便我可以从中间运行脚本,例如从第 500 次测试到第 600 次或从第 430 次测试到第 450 次测试等等。我尝试在我的代码中编辑所有可能的值,但没有用。有人可以帮我破解吗?

发布代码

Option Explicit

Dim j
Dim qcServer
Dim tdc
Dim testset
Dim TSetFact
Dim tsTreeMgr
Dim npath
Dim tsFolder
Dim tsList
Dim tSetName


qcServer = "http://testdirector.mot.com/qcbin"
'nPath = "Root\Execution\Build_1.0"
nPath = "Root\Execution\Build_1.0"
tSetName  = "Test Folder"


WScript.Echo qcserver

Set tdc = CreateObject("tdapiole80.tdconnection")

tdc.InitConnectionEx qcServer

tdc.Login "username", "password"

tdc.Connect "DEFAULT", "TEAMMate"

If tdc.ProjectConnected = True Then
WScript.Echo "Connected to the Project Columbus"
End If

WScript.Echo "Logged in ??"
WScript.Echo tdc.LoggedIn 
WScript.Echo "Connected ??"
WScript.Echo tdc.Connected 
WScript.Echo "Server name"
WScript.Echo tdc.ServerName 
WScript.Echo "Domain name"
WScript.Echo tdc.DomainName
WScript.Echo "Project name"
WScript.Echo tdc.ProjectName 
WScript.Echo "username"
WScript.Echo tdc.UserName 


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

If tsFolder Is Nothing Then
WScript.Echo "Testset folder not found"
End If
WScript.Echo "Test set folder exists"

Set tsList = tsFolder.FindTestSets(tSetName)

If tsList Is Nothing Then
WScript.Echo "Testset not found"
End If

If tsList.Count > 1 Then
WScript.Echo "Multiple Testsets found with same name"
End If
If tsList.Count < 1 Then
WScript.Echo "Testset not found"
End If

WScript.Echo "Testset exists"
Set testset = tsList.Item(1)
WScript.Echo testSet.Name

Dim TSTestFact
Dim TestSetTestsList
Dim thetest



    Set TSTestFact = testSet.TSTestFactory
    Set TestSetTestsList = TSTestFact.NewList("")
    j = 0

    Dim sID
    Dim sName

    For Each thetest In TestSetTestsList
    j = j + 1 
    If j > 737 Then    **j > 737 indicates run up to 737th test in the test lab) **
    Exit For
    End If 
    'sID = thetest.ID
    sName = thetest.Name
    'WScript.Echo sID
    If j > 0 Then 
    WScript.Echo "testcase found for execution"
    Dim runName
    Dim RunF
    Dim theRun
    Dim runStepF
    Dim lst
    Dim Item
    Dim runtitle

    'Set runtitle = "Run"

    runName = thetest.ID
    Set RunF = thetest.RunFactory
    Set theRun = RunF.AddItem(runName)
    theRun.Status = "Passed"
    theRun.Post   

    theRun.CopyDesignSteps
    theRun.Post 

    Set runStepF = theRun.StepFactory
    Set lst = runStepF.NewList("")
    For Each Item In lst
     Item.Status = "Passed"
     Item.Post
    Next    
    End If     
    WScript.Echo sName
    Next

'Set ObjRun = QCUtil.CurrentRun
'Dim sf1 as StepFactory
'Dim s1 as step

'Set sf1 = ObjRun.StepFactory
'Set s1 = sf1.NewList("")

'For i = 1 To s1.count
's1.Item(i).Field("ST_EXPECTED") = "Your Expected"
's1.Item(i).Field("ST_ACTUAL") = "Your Actual"

'Next

's1.Post

'Disconnect
If tdc.Connected Then
tdc.Disconnect
WScript.Echo "Disconnected QC session successfully"
End If

'Log off the server
If tdc.LoggedIn Then
tdc.Logout
WScript.Echo "Logged off from the Server successfully"
End If

'Release the TDConnection object.
tdc.ReleaseConnection
WScript.Echo "Released the connection"
'Check status
Set tdc = Nothing
4

1 回答 1

1

看来代码应该适用于编号为 737 或更大的测试用例。另请查看 Quality Center 帮助以获取可能有帮助的 OTA 参考。您可以从此处下载 Mercury Quality Center Open Test Architecture API 参考(OTA_API_Reference.chm) 和站点管理 API 参考 (Site_Admin_API_Reference.chm) 文件:http: //technologicaguru.blogspot.com.au/2008/03/quality-center -open-test-architecture.html

自己没有尝试过,乍一看,您可以尝试用以下代码替换部分代码,指定要查询的测试用例编号范围的上下限:

Dim sID
Dim sName
Dim testCaseStart
Dim testCaseEnd
'Change testCaseStart and testCaseEnd to required test case range 
testStartVal = 500
testEndVal = 600

For Each thetest In TestSetTestsList
  If j >= testCaseStart And j <= testCaseEnd then 
    'sID = thetest.ID
    sName = thetest.Name
    'WScript.Echo sID
    If j > 0 Then 
      WScript.Echo "testcase found for execution"
      Dim runName
      Dim RunF
      Dim theRun
      Dim runStepF
      Dim lst
      Dim Item
      Dim runtitle

      'Set runtitle = "Run"

      runName = thetest.ID
      Set RunF = thetest.RunFactory
      Set theRun = RunF.AddItem(runName)
      theRun.Status = "Passed"
      theRun.Post   

      theRun.CopyDesignSteps
      theRun.Post 

      Set runStepF = theRun.StepFactory
      Set lst = runStepF.NewList("")
      For Each Item In lst
        Item.Status = "Passed"
        Item.Post
      Next    
    End If     
    WScript.Echo sName
  End If
  j = j + 1
Next
于 2012-09-24T07:51:32.367 回答