''The class use to report result ''''===========Demo to use this class===================== 'Dim oReporter 'Set oReporter = new Report 'oReporter.Set_Parent_Node("in") 'oReporter.Pass "test", "testpass" 'oReporter.Set_Parent_Node("in") 'oReporter.Fail "test", "testpass" 'oReporter.Unset_Parent_Node("out") 'oReporter.Set_Parent_Node("in") 'oReporter.Done "test", "testpass" 'oReporter.Unset_Parent_Node("out") 'oReporter.Unset_Parent_Node("out") ''''===========Demo to use this class===================== Class Report Dim fso, imgpath, stack_point, stack(10), xml_obj Public Sub Pass(v_title, v_des) g_Test_Pass_Count = g_Test_Pass_Count + 1 v_title = v_title & " 【PASS】" Call Log_Result(micPass, v_title, v_des) End Sub Public Sub Fail(v_title, v_des) g_Test_Fail_Count = g_Test_Fail_Count + 1 v_title = v_title & " 【FAIL】" Call Log_Result(micFail, v_title, v_des) Call Log_XML_Result(v_title, v_des, Filename & ".png") End Sub Public Sub Done(v_title, v_des) g_Test_Done_Count = g_Test_Done_Count + 1 v_title = v_title & " 【DONE】" Call Log_Result(micDone, v_title, v_des) Call Log_XML_Result(v_title, v_des, Filename & ".png") End Sub Public Sub Set_Parent_Node(str_node_name) stack_point = stack_point + 1 stack(stack_point) = Reporter.GetContext() str_detail = "区块测试开始节点" int_icon = 202 node_Context = Custom_Node(micDone, str_node_name + "【开始节点】", str_detail, int_icon) Reporter.SetContext node_Context End Sub Public Sub Unset_Parent_Node(str_node_name) Reporter.SetContext stack(stack_point) stack_point = stack_point - 1 str_detail = "区块测试开始节点" int_icon = 202 node_Context = Custom_Node(micDone, str_node_name + "【结束节点】", str_detail, int_icon) End Sub Private Function Custom_Node(status, str_node_name, str_detail, int_icon) Set dicMetaDescription = CreateObject("Scripting.Dictionary") dicMetaDescription("Status") = status dicMetaDescription("PlainTextNodeName") = str_node_name ' 设置节点的详细描述信息(可以使用HTML格式) dicMetaDescription("StepHtmlInfo") = str_detail dicMetaDescription("DllIconIndex") = int_icon dicMetaDescription("DllIconSelIndex") = int_icon dicMetaDescription("DllPAth") = "D:\Program Files\HP\QuickTest Professional\bin\ContextManager.dll" Custom_Node = Reporter.LogEvent("User", dicMetaDescription, Reporter.GetContext) End Function Private Sub Log_Result(v_result, v_title, v_des) desktop.CaptureBitmap imgpath, True Reporter.ReportEvent v_result, v_title, v_des, imgpath Call My_logger(v_result & ":" & v_title & ":" & v_des & ":" & imgpath , 1) End Sub Private Sub Log_XML_Result(v_title, v_des, Img_path) Set obj_page = Browser("CreationTime:=0").Page("index:=") If obj_page.Exist(1) Then str_url = obj_page.GetROProperty("url") str_title = obj_page.GetROProperty("title") else str_url = "null" str_title = "no browser exist" End If xml_obj.add_pagename(str_title) xml_obj.add_url(str_url) xml_obj.add_element(g_current_element) xml_obj.add_function(g_current_function) xml_obj.add_reason(v_title) xml_obj.add_detail(v_des) xml_obj.add_screen(Img_path) xml_obj.add_index(Replace(time, ":", "")) End Sub Private Sub Class_Initialize ' Setup Initialize event. stack_point = 0 Set xml_obj = new XML xml_obj.init g_result_file imgpath = g_Temp_Dir & "\img\" Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FolderExists(g_Temp_Dir) Then fso.CreateFolder(g_Temp_Dir) End If If Not fso.FolderExists(imgpath) Then fso.CreateFolder(imgpath) End If Filename = Replace(now,":","") Filename = Replace(Filename," ","") Filename = Replace(Filename,"-","") Filename = Replace(Filename,"/","") imgpath = imgpath & Filename & ".png" End Sub Private Sub Class_Terminate ' Setup Terminate event. Set fso = nothing End Sub End Class
支持节点的展示形式:
1
2
3
44
3
2
1