2

我的目标是最终使用 QTP 将测试用例结果从 Excel 写回 QC。我设计了一个自动化框架,但需要将这些结果传递到 Quality Center 中的相应测试用例中。我有这段代码,它在“tcase(j).Field("TC_STATUS")= test_status”行给了我一个“一般运行错误”。

我对其进行了调试,并且在该行之前它看起来工作正常。有什么建议么?

test_set_name = "test" 
test_name = "test1" 
test_status = "FAILED" 


Call connect_to_QC()

Call update_test_status(test_set_name,test_name ,test_status)

'Closing the TD connection
udv_tdc.releaseConnection



Function connect_to_QC

   qcUser = ""
   qcPassword = ""
   qcDomain = ""
   qcProject = "Web_"
   folder_path="Root\" ' the path of the folder which contains your test set
   udv_qcServer = "<server:port/qcbin>"

   Set udv_tdc = CreateObject("TDApiOle80.TDConnection")
   'Initialise the Quality center connection
   udv_tdc.InitConnectionEx udv_qcServer

   'Loging the username and password
   udv_tdc.Login qcUser, qcPassword

   'connecting to the domain and project
   udv_tdc.Connect qcDomain, qcProject

End Function

Function update_test_status(test_set_name, test_name,test_status)

    folder_path="Root\EMS - Engagement Management System\EMS Test Team\EMS - Work Source\" ' the path of the folder which contains your test set

   set udv_tdc = Qcutil.QCConnection

   Set TSetFact = udv_tdc.TestSetFactory
   Set tsTreeMgr = udv_tdc.TestSetTreeManager
   Set TestSetFolder1=tsTreeMgr.NodeByPath(folder_path)   
   set tsff = TestSetFolder1.TestSetFactory.Filter
   tsff.Filter("CY_CYCLE")= test_set_name

   set tsl = tsff.NewList()

   If tsl.count = 0 Then
      Print "Test set with the name " & test_set_name & " is not found "
   End If

   For i=1 to tsl.count

      Set ts = tsl.Item(i)
      Set test_case_filter = ts.TSTestFactory.Filter
      filter_string= Chr(34) & "*" & test_name & "*" &Chr(34)
      test_case_filter.Filter("TS_NAME")=filter_string
      Set tcase=test_case_filter.NewList()

      If tcase.count = 0 Then
         Print "Test case with the name " & test_name & " is not found "
      End If

      For j=1 to tcase.count
         tcase(j).Field("TC_STATUS")= test_status
         tcase(j).Post
      Next   ' End of test CASE loop

   Next   'End of test SET loop

End Function
4

0 回答 0