Set Wshshell = CreateObject("Wscript.shell")
Set TDConn = CreateObject("TDApiOle80.TDConnection.1")
Set tsTreeMgr = TDConn.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath("Root\" & Trim(tsFolderName))
Set tsList = tsFolder.FindTestSets(tSetName)
Set theTestSet = tsList.Item(1)
Set TSTestFact = theTestSet.TSTestFactory
Set TestSetTestsList = TSTestFact.NewList("")
testCaseNum = TestSetTestsList.Count
For i = 1 To testCaseNum
TestSetTestsList.Item(i).Status = "Passed"
TestSetTestsList.Item(i).Post
Next
Set TestSetTestsList = Nothing
Set TSTestFact = Nothing
Set theTestSet = Nothing
Set tsList = Nothing
Set tsFolder = Nothing
Set tsTreeMgr = Nothing
Set TDConn = Nothing作者: lyscser 时间: 2010-10-24 11:39
run表的顺序我已经用QTP打出来了
Set fieldList = TDConn.Fields("run")
For i = 1 to fieldList.Count
Set colField = fieldList.Item(i)
Print "'The "&i&"th item is " & colField.Name
Next
'The 01th item is RN_OS_BUILD
'The 02th item is RN_OS_NAME
'The 03th item is RN_OS_SP
'The 04th item is RN_TEST_ID
'The 05th item is RN_TESTCYCL_ID
'The 06th item is RN_TEST_VERSION
'The 07th item is RN_CYCLE
'The 08th item is RN_TEST_INSTANCE
'The 09th item is RN_TESTER_NAME
'The 10th item is RN_DURATION
'The 11th item is RN_ATTACHMENT
'The 12th item is RN_PATH
'The 13th item is RN_OS_CONFIG
'The 14th item is RN_CYCLE_ID
'The 15th item is RN_VC_VERSION
'The 16th item is RN_VC_LOKEDBY
'The 17th item is RN_VC_STATUS
'The 18th item is RN_RUN_ID
'The 19th item is RN_RUN_NAME
'The 20th item is RN_EXECUTION_DATE
'The 21th item is RN_EXECUTION_TIME
'The 22th item is RN_HOST
'The 23th item is RN_STATUS
'The 24th item is RN_RUN_VER_STAMP
'The 25th item is RN_USER_01
'The 26th item is RN_USER_02
'The 27th item is RN_USER_03
'The 28th item is RN_USER_04
'The 29th item is RN_USER_10
'The 30th item is RN_USER_05
'The 31th item is RN_USER_11
'The 32th item is RN_USER_06
'The 33th item is RN_USER_12
'The 34th item is RN_USER_07
'The 35th item is RN_USER_08
'The 36th item is RN_USER_09
'The 37th item is RN_VTS作者: lyscser 时间: 2010-10-24 19:21
嘿嘿,琢磨了一下,终于弄清楚了,要是这些方法有中文说明文档多好啊……
Set tsTreeMgr = TDConn.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath("Root\" & Trim(tsFolderName))
Set tsList = tsFolder.FindTestSets(tSetName)
Set theTestSet = tsList.Item(1)
Set TSTestFact = theTestSet.TSTestFactory
Set TestSetTestsList = TSTestFact.NewList("")
testCount = TestSetTestsList.Count
For i = 1 To testCount
Set TheSpecifiedTest = TestSetTestsList.Item(i)
Set TheRunFactory = TheSpecifiedTest.RunFactory
Set theRun = TheRunFactory.AddItem("Run_"&Month(Date)&"-"&Day(Date)&"_"&Hour(Time)&"-"&Minute(Time)&"-"&Second(Time))
theRun.status = "Passed"
theRun.Field("RN_HOST") = "FUDANXIANG"
theRun.Field("RN_DURATION") = "125"
theRun.Field("RN_TESTER_NAME") = "admin"
theRun.Post
Next作者: lyscser 时间: 2010-10-24 19:23
不过这个办法无法修改现有的运行,只能新增一个现有的运行
这个地儿的instance id可以根据实际要修改的时间生成
Set theRun = TheRunFactory.AddItem("Run_"&Month(Date)&"-"&Day(Date)&"_"&Hour(Time)&"-"&Minute(Time)&"-"&Second(Time))作者: yzylion 时间: 2010-10-25 08:42
很好很强大作者: lyscser 时间: 2010-10-27 23:46
终极版本,作弊无极限……造成一切后果本人谢绝承担责任
Public Sub Modify_QC_Run_Fields(fileFullPath,myStatus,newVersionNo)
'On Error Resume Next
Set Wshshell = CreateObject("Wscript.shell")
Set TDConn = CreateObject("TDApiOle80.TDConnection.1")
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(fileFullPath,False,True)
If TDConn.Connected = False Then
TDConn.InitConnectionEx "http://192.168.1.103:8080/qcbin"
TDConn.Login "LIUYI",""
TDConn.Connect "MYDOM","automation"
Else
TDConn.Disconnect()
TDConn.Logout()
TDConn.ReleaseConnection()
TDConn.InitConnectionEx "http://192.168.1.103:8080/qcbin"
TDConn.Login "LIUYI",""
TDConn.Connect "MYDOM","automation"
End If
intRow = 1
Do Until Trim(objExcel.Cells(intRow,1).Value) = ""
Set tsTreeMgr = TDConn.TestSetTreeManager
Set tsFolder = tsTreeMgr.NodeByPath("Root\" & Trim(tsFolderName))
Set tsList = tsFolder.FindTestSets(tSetName)
If tsFolder Is Nothing Then
Wshshell.Popup "找不到路径【" & nPath&"】",1,"运行时错误:",0
Set tsList = Nothing
Set tsFolder = Nothing
Set tsTreeMgr = Nothing
Set TDConn = Nothing
Set Wshshell = Nothing
End If
If tsList.Count < 1 Then
Wshshell.Popup "找不到测试集!【" & tSetName&"】",1,"运行时错误:",0
Set tsList = Nothing
Set tsFolder = Nothing
Set tsTreeMgr = Nothing
Set TDConn = Nothing
Set Wshshell = Nothing
End If
Set theTestSet = tsList.Item(1)
theTestSet.Field("CY_USER_01") = newVersionNo
theTestSet.Field("CY_STATUS") = "Open"
theTestSet.Field("CY_OPEN_DATE") = Date
theTestSet.Post
Set TSTestFact = theTestSet.TSTestFactory
Set TestSetTestsList = TSTestFact.NewList("")
testCount = TestSetTestsList.Count
For i = 1 To testCount
Set TheSpecifiedTest = TestSetTestsList.Item(i)
theTestId= TheSpecifiedTest.TestId
stepCount = TheSpecifiedTest.Field("TS_STEPS")
Select Case TheSpecifiedTest.Field("TS_TYPE")
Case "MANUAL"
mySpecifiedHost = "HSH-9376"
mySpecifiedTester = "LIUYI"
Case "QUICKTEST_TEST"
mySpecifiedHost = myHost
mySpecifiedTester = "admin"
Case Else
Wscript.Echo "您选择了一个既非QTP脚本也非手工测试案例的实例,请确认!"
End Select
Set MyRunInstanceFactory = TheSpecifiedTest.RunFactory
Set MyRunInstance = MyRunInstanceFactory.AddItem("Run_"&Month(Date)&"-"&Day(Date)&"_"&Hour(Time)&"-"&Minute(Time)&"-"&Second(Time))
Set TheTestStepFact = MyRunInstance.StepFactory
Set TDCom = TDConn.Command
TDCom.CommandText = "select * from dessteps where ds_test_id = "&theTestId
Set RecSet = TDCom.Execute
RecSet.First
For v = 1 to stepCount
operDesc = RecSet.FieldValue("DS_DESCRIPTION")
expectDesc = RecSet.FieldValue("DS_EXPECTED")
Set TheTestRunStep = TheTestStepFact.AddItem(NULL)
TheTestRunStep.Field("ST_STEP_NAME") = "步骤 "&v
TheTestRunStep.Field("ST_STATUS") = myStatus
TheTestRunStep.Field("ST_EXECUTION_DATE") = Date
TheTestRunStep.Field("ST_EXECUTION_TIME") = Time
TheTestRunStep.Field("ST_DESCRIPTION") = operDesc
TheTestRunStep.Field("ST_EXPECTED") = expectDesc
TheTestRunStep.Field("ST_ACTUAL") = expectDesc
TheTestRunStep.Field("ST_PATH") = TheSpecifiedTest.Name
TheTestRunStep.Field("ST_STEP_ORDER") = v
TheTestRunStep.Post
If v < stepCount Then
RecSet.Next
End If
Next
MyRunInstance.Field("RN_STATUS") = myStatus
MyRunInstance.Field("RN_HOST") = mySpecifiedHost
MyRunInstance.Field("RN_DURATION") = Trim(Int((180-60+1)*Rnd+60))
MyRunInstance.Field("RN_TESTER_NAME") = mySpecifiedTester
MyRunInstance.Field("RN_EXECUTION_DATE") = Date
MyRunInstance.Field("RN_EXECUTION_TIME") = Time
MyRunInstance.Post
TheSpecifiedTest.Field("TC_ACTUAL_TESTER") = mySpecifiedTester
TheSpecifiedTest.Field("TC_EXEC_DATE") = Date
TheSpecifiedTest.Field("TC_EXEC_TIME") = Time
TheSpecifiedTest.Field("TC_STATUS") = myStatus
TheSpecifiedTest.Post
Set RecSet = Nothing
Set TDCom = Nothing
Set TheTestRunStep = Nothing
Set TheTestStepFact = Nothing
Set MyRunInstance = Nothing
Set MyRunInstanceFactory = Nothing
Set TheSpecifiedTest = Nothing
Next
Set TestSetTestsList = Nothing
Set TSTestFact = Nothing
Set theTestSet = Nothing
Set tsList = Nothing
Set tsFolder = Nothing
Set tsTreeMgr = Nothing
intRow = intRow + 1
Loop
objExcel.Quit
Set objWorkbook = Nothing
Set objExcel = Nothing
Set TDConn = Nothing