未来已来

QC 9.2 OTA 代码实例 - 读取QC中的bug列表输出到Excel报表中

上一篇 / 下一篇  2008-08-08 23:05:07 / 个人分类:测试流程

   把qc服务器上bug输出到本地excel表中,利用Quality Center Open Test Architecture API -OTA COM 9.0编写脚本代码读取服务器上bug列表,以下代码在vb中编写,调试通过。

 注意:The OTAClient.dll (OTA COM 9.0 Type Library) 从服务器上下载后保存在你本机文件夹
\Program Files\Common Files\Mercury Interactive\Quality Center下。

代码:    

     Dim QCConnection As TDConnection
     Dim BugFactory As BugFactory
    
     Dim BugList
     Dim Bug As Bug
     Dim Row As Integer
     Dim Excel, Sheet
         
         
     On Error GoTo makeConnectionErr
    
     If (QCConnection Is Nothing) Then
        Set QCConnection = New TDAPIOLELib.TDConnection
     End If
   
     If (QCConnection Is Nothing) Then GoTo makeConnectionErr
    

         
    
     QCConnection.InitConnectionEx "http://192.168.1.180:8080/qcbin"
     QCConnection.Login "pcl", ""
     'DEFAULT = Domain, QualityCenter_Demo = Project
     QCConnection.Connect "深圳博为峰信息技术有限公司", "mis"
    
     If QCConnection.Connected = True Then
       
       
       
        Debug.Print "Connection Success"
       
        If QCConnection.LoggedIn = True Then
        Debug.Print "Logedin"
        If QCConnection.ProjectName <> "mis" Then
            
             If QCConnection.ProjectConnected = True Then
                Debug.Print "ok"
             End If
         End If
      End If
    
     Else
        MsgBox "Connection Failed"
     End If
    
     'Check status.
     
            
           
        

 

     Set BugFactory = QCConnection.BugFactory
     Set BugList = BugFactory.NewList("")
    
    
    
     Set Excel = CreateObject("Excel.Application")
     Excel.WorkBooks.Add
     Set Sheet = Excel.ActiveSheet


    Row = 1
        Sheet.Cells(Row, 1).Value = "BG_BUG_ID"
        Sheet.Cells(Row, 2).Value = "Summary"
        Sheet.Cells(Row, 3).Value = "DetectedBy"
        Sheet.Cells(Row, 4).Value = "Priority"
        Sheet.Cells(Row, 5).Value = "Status"
        Sheet.Cells(Row, 6).Value = "AssignedTo"
     
   Row = 2
   For Each Bug In BugList
        Sheet.Cells(Row, 1).Value = Bug.Field("BG_BUG_ID")
        Sheet.Cells(Row, 2).Value = Bug.Summary
        Sheet.Cells(Row, 3).Value = Bug.DetectedBy
        Sheet.Cells(Row, 4).Value = Bug.Priority
        Sheet.Cells(Row, 5).Value = Bug.Status
        Sheet.Cells(Row, 6).Value = Bug.AssignedTo
        Row = Row + 1
    Next

    Excel.ActiveWorkbook.SaveAs ("c:\QualityCenter_DEFECTS.xls")
    Excel.Quit

    Set Excel = Nothing
    Set BugList = Nothing
   
    QCConnection.ReleaseConnection
    Set QCConnection = Nothing
makeConnectionErr:
   Debug.Print Err, fName, Err.Descrīption & vbCrLf & errmsg
 


TAG: 测试流程

Angel-我的天使 引用 删除 zhangaibing   /   2009-04-20 11:43:17
朴老师在这个重要的日子写下的东东,对今天的我受益颇深啊。。谢谢
 

评分:0

我来说两句

Open Toolbar