工欲善其事 必先利其器

<原创>一个批处理执行Test的VBS脚本

上一篇 / 下一篇  2007-08-03 10:35:04 / 个人分类:测试技术

BatchRun.vbs(转载请注明出处)

同目录下需存在runlist.txt文件,保存需要批量运行的test路径,形如:

c:\autotest\test1
c:\autotest\test2

------------------

On Error Resume Next
error.clear
Dim qtApp
Dim qtTest
Dim qtResultsOpt
Dim fso, MyFile,TestName
Const ForReading = 1, ForWriting = 2

Set WshShell = CreateObject("Wscrīpt.Shell")
WshShell.Popup "开始批量执行自动化测试脚本!", 3, "my AutoTest", 0 + 64

Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch

qtApp.Visible = True
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

Set fso = CreateObject("scrīpting.FileSystemObject")
Set MyFile = fso.OpenTextFile(".\RunList.txt", ForReading, True)
Do While MyFile.AtEndOfStream <> True
 TestName = MyFile.ReadLine

 qtApp.Open TestName, True
 Set qtTest = qtApp.Test
 qtTest.Settings.Run.OnError = "Dialog"
 
 Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
 qtResultsOpt.ResultsLocation = TestName &"\AutoRes"
 
 qtTest.Run qtResultsOpt, True
 qtTest.close
 wait 1
Loop

MyFile.Close
qtApp.Quit

MsgBox "自动化测试脚本执行完毕!脚本测试结果存放在各自的AutoRes目录下,请用QTP result工具查看"

Set fso = Nothing
Set qtResultsOpt = Nothing  
Set qtTest = Nothing 
Set qtApp = Nothing
Set WshShell = Nothing


TAG:

 

评分:0

我来说两句

Open Toolbar