|
6#
楼主 |
发表于 2010-10-27 23:46:52
|
只看该作者
终极版本,作弊无极限……造成一切后果本人谢绝承担责任
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) = ""
tsFolderName = objExcel.Cells(intRow, 1).Value
tSetName = objExcel.Cells(intRow, 2).Value
myHostint = int((286-271+1)*rnd+271)
myHost = "CNSH020"&Trim(myHostint)
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
End Sub
Call Modify_QC_Run_Fields("D:\Documents\测试工具文档\VBS\my_testset.xls","Passed","MYTest-NEWTest1.0.2") |
|