您的位置:首页 > 编程语言 > Qt开发

修改完善的写log文件的QTP脚…

2015-05-30 11:30 393 查看
好文要顶!!!!!!!!!!!!原文地址:修改完善的写log文件的QTP脚本作者:阿雁Public Sub WriteLogs(result)

Const ForReading = 1, ForWriting = 2,
ForAppending = 8

Dim fileSystemObj, fileSpec

Dim currentTime, currentDate, logName, logFile,
message

currentDate = Date

currentTime = Time

logName = "log"

Set fileSystemObj =
CreateObject("scrīpting.FileSystemObject")

fileSpec ="D:"
&logName& ".txt" 'change this
according to your directory

If not (fileSystemObj.FileExists(fileSpec))
Then

Set logFile =
fileSystemObj.CreateTextFile(fileSpec,
True)

logFile.WriteLine
("############################################################################################")

logFile.WriteLine (currentDate
& " " &
currentTime & " Test: " &
environment.Value("TestName") )

logFile.WriteLine
("############################################################################################")

logFile.Close

Set logFile = Nothing

End If

Set logFile =
fileSystemObj.OpenTextFile(fileSpec, ForAppending, False)

'result = "本测试用例通过!"

logFile.WriteLine (currentDate &
" " & currentTime
& " " & result
)

logFile.Close

Set logFile = Nothing

Set fileSystemObj = Nothing

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: