如何从命令行运行 QTP 测试?

编程入门 行业动态 更新时间:2024-10-24 04:50:31
本文介绍了如何从命令行运行 QTP 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在某些情况下,我需要从命令提示符启动和运行 QTP 测试.例如,我想使用 Windows 任务计划程序在整个晚上的不同时间运行 QTP 测试,但是(似乎)没有我可以使用的标志来打开 QTP.exe 并运行测试.我怎样才能做到这一点?

There are a few situations where I need to launch and run a QTP test from the command prompt. For example, I'd like to use Windows Task Scheduler to run QTP tests at various times throughout the night, but there is (seemingly) no flag that I can use have QTP.exe open and run a test. How can I accomplish this?

推荐答案

确实,使用 QuickTest Pro,您不能直接通过调用 C:Program Files (x86) 来运行测试HPQuickTest ProfessionalinQTPro.exe "C:Some Test"然而,所有的希望都没有丧失.有一种方法可以创建一个小的 VBS 文件,该文件可以在调用该 VBS 文件时运行任意 QTP 测试.这比为每个测试创建一个批处理文件要好得多.

It's true that with QuickTest Pro, you cannot directly run a test by calling C:Program Files (x86)HPQuickTest ProfessionalinQTPro.exe "C:Some Test" All hope is not lost, however. There is a way to create a small VBS file that can run any arbitrary QTP test when that VBS file is called. This is much better than creating a single batch file for each and every test.

'******************************************************************* 'RunThisTest 'by Michael Innes 'November 2012 testResourcePath = "C:Test Logs and Results" 'Getting the test path Dim objArgs Set objArgs = wscript.Arguments testPath = objArgs(0) 'Determining that the test does exist Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") DoesFolderExist = objFSO.FolderExists(testPath) Set objFSO = Nothing If DoesFolderExist Then Dim qtApp 'Declare the Application object variable Dim qtTest 'Declare a Test object variable Set qtApp = CreateObject("QuickTest.Application") 'Create the Application object qtApp.Launch 'Start QuickTest qtApp.Visible = True 'Make the QuickTest application visible qtApp.Open testPath, False 'Open the test in read-only mode Set qtTest = qtApp.Test 'Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object 'qtResultsOpt.ResultsLocation = testResourcePath ' Specify the location to save the test results. 'qtTest.Run qtResultsOpt,True 'Run the test and wait until end of the test run qtTest.Run 'Run the test qtTest.Close 'Close the test qtApp.Quit Else 'Couldn't find the test folder. That's bad. Guess we'll have to report on how we couldn't find the test. 'Insert reporting mechanism here. End If

要使用上面的代码,请执行如下命令:cscript.exe "C:RunThisTest.vbs" "L:Test PathThe Test Itself"

To use the code above, execute a command like this: cscript.exe "C:RunThisTest.vbs" "L:Test PathThe Test Itself"

更多推荐

如何从命令行运行 QTP 测试?

本文发布于:2023-11-08 11:28:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   测试   QTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!