How can I run a QTP test from the command line?

谁说我不能喝 提交于 2019-12-28 16:22:25

问题


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?


回答1:


It's true that with QuickTest Pro, you cannot directly run a test by calling C:\Program Files (x86)\HP\QuickTest Professional\bin\QTPro.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

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




回答2:


The Multithreaded Driver tool can execute the script for you.

> mdrv.exe -usr "c:\test\foo.usr"


来源:https://stackoverflow.com/questions/13907603/how-can-i-run-a-qtp-test-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!