从QTP到QC的测试用例写入通过/失败

时间:2014-08-05 19:47:00

标签: automation qtp hp-quality-center qc hp-uft

我的目标是最终使用QTP将测试用例结果从Excel写回到QC。我设计了一个自动化框架,但需要将这些结果传递到Quality Center中的相应测试用例。我有这个代码,它给了我一个"一般运行错误" at line" 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

0 个答案:

没有答案
相关问题