TA的每日心情 | 慵懒 2015-1-18 20:39 |
---|
签到天数: 2 天 连续签到: 1 天 [LV.1]测试小兵
|
这个在前台手工快速设置目前也没有找到好的方法,不过新工程的话,可以通过vbs脚本启动自动加载外部资源及相应设置,使用Dictionary创建数组来管理外部资源,源码如下,可以参考下
Function Add_ARRAY_Library(pathName, byref itemCount)
Call ARRAY_Library.Add(cstr(itemCount), pathName)
itemCount = itemCount + 1
End Function
Function Add_ARRAY_Library_Delete(pathName, byref itemCount)
Call ARRAY_Library_Delete.Add(cstr(itemCount), pathName)
itemCount = itemCount + 1
End Function
Function IsExist(pathName)
IsExist = false
For j= 0 to ARRAY_Library.Count -1
If ARRAY_Library.Item(cstr(j)) = pathName Then
IsExist = true
Exit function
End If
Next
End Function
Dim MainPath, fso
Dim ARRAY_Library
Set ARRAY_Library = CreateObject("Scripting.Dictionary")
Dim ARRAY_Library_Delete
Set ARRAY_Library_Delete = CreateObject("Scripting.Dictionary")
MainPath = createobject("wscript.shell").currentdirectory & "\Main"
Set fso = CreateObject("scripting.filesystemobject")
Set qtApp = CreateObject("QuickTest.Application")
If not qtApp.Launched Then
If not fso.FolderExists(MainPath) then
MsgBox MainPath & "路径不存在!" & vbCr & "请将VBS文件放到与Main平级的目录下执行!" & vbCr & "谢谢!", ,"Main路径错误"
Wscript.Quit
End If
qtApp.Launch
qtApp.Open MainPath
qtApp.Visible = true
End If
Set fso = nothing
qtApp.Folders.RemoveAll
qtApp.Folders.Add(createobject("wscript.shell").currentdirectory & "\Addin")
qtApp.Folders.Add(createobject("wscript.shell").currentdirectory & "\Private")
qtApp.Folders.Add(createobject("wscript.shell").currentdirectory & "\Scripts")
'清除所有资源
qtApp.Test.Settings.Resources.Libraries.RemoveAll
'加载私有项目资源
Dim pos, delete_pos
pos = 0
delete_pos = 0
Call Add_ARRAY_Library("ProjectInit.vbs", pos)
'加载公共项目资源
Call Add_ARRAY_Library("ICall.dll", pos)
Call Add_ARRAY_Library("Recovery.vbs", pos)
'加载项目脚本
Call Add_ARRAY_Library("PUB\DosOracleExp.vbs", pos)
For i = 0 to ARRAY_Library.Count - 1
pathName = ARRAY_Library.Item(cstr(i))
If cstr(qtApp.Test.Settings.Resources.Libraries.Find(pathName)) = cstr(-1) then
call qtApp.Test.Settings.Resources.Libraries.Add(pathName)
end if
Next
'原来类库中存在的则删除
For i = 1 to qtApp.Test.Settings.Resources.Libraries.Count
If not IsExist(qtApp.Test.Settings.Resources.Libraries.Item(i)) then
Call Add_ARRAY_Library_Delete(qtApp.Test.Settings.Resources.Libraries.Item(i), delete_pos)
end if
Next
For i = 0 to ARRAY_Library_Delete.Count - 1
call qtApp.Test.Settings.Resources.Libraries.Remove(ARRAY_Library_Delete.Item(cstr(i)))
next
'直接运行
qtApp.Test.Run
Set qtApp = nothing |
|