Web测试
写HTML日志
上一篇 /
下一篇 2013-07-25 22:37:45
/ 个人分类:测试总结
Const Forreading=1,ForWriting=2,ForAppending=8
'''创建html日志头部
Function CreateHtmlLog()
Dim fso,htmlLog
Set fso=CreateObject("scripting.FileSystemObject")
Set htmlLog=fso.OpenTextFile("D:\test.txt",ForAppending) '文件地址可参数化
htmlLog.WriteLine("<html>")
htmlLog.WriteLine("<head>")
htmlLog.WriteLine("<title>")
htmlLog.WriteLine("TestReport")
htmlLog.WriteLine("</title>")
htmlLog.WriteLine("</head>")
htmlLog.WriteLine("<body>")
htmlLog.WriteLine("<table>")
htmlLog.WriteLine("<tr>")
htmlLog.WriteLine("<td colspan='6' bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>测试报告</b></td>")
htmlLog.WriteLine("</tr>")
htmlLog.WriteLine("<tr>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>TestCaseName</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>TestCaseID</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='10%' align='center'><b>TestResult</b></td>")
htmllog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='10%' align='center'><b>TestTime</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>ActualValue</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>ExceptValue</b></td>")
htmlLog.WriteLine("</tr>")
Set htmlLog=Nothing
Set fso=Nothing
End Function
'''写html日志
Function WriteHtmlLog(TestCaseName,TestCaseID,TestResult,TestResult,TestResult,ExceptValue)
Dim fso,htmlLog
Set fso=CreateObject("scripting.FileSystemObject")
Set htmlLog=fso.OpenTextFile("D:\test.txt",ForAppending) '文件地址可参数化
htmlLog.WriteLine("<tr>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>"&TestCaseName&"</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>"&TestCaseID&"</b></td>")
'如果测试结果为PASS,则用绿色字体,如果测试结果为Fail,则用红色字体
If TestResult="PASS" Then
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='10%' align='center'><font color="Green"><b>"&TestResult&"</b></font></td>")
Else
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='10%' align='center'><font color="red"><b>"&TestResult&"</b></font></td>")
End If
htmllog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='10%' align='center'><b>"&TestTime&"</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>"&ActualValue&"</b></td>")
htmlLog.WriteLine("<td bgcolor='#CCCCCC' height='40' width='20%' align='center'><b>"&ExceptValue&"</b></td>")
htmlLog.WriteLine("</tr>")
htmlLog.WriteLine("</table>")
htmlLog.WriteLine("</body>")
htmlLog.WriteLine("</html>")
Set htmlLog=Nothing
Set fso=Nothing
End Function
收藏
举报
TAG: