簡體   English   中英

如何從命令行運行QTP測試?

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

在某些情況下,我需要從命令提示符啟動並運行QTP測試。 例如,我想使用Windows任務計划程序在整個晚上的不同時間運行QTP測試,但是(看似)沒有可以使用QTP.exe打開並運行測試的標志。 我怎么能做到這一點?

確實,使用QuickTest Pro,您無法通過調用C:\\Program Files (x86)\\HP\\QuickTest Professional\\bin\\QTPro.exe "C:\\Some Test\\" 直接運行測試
然而,所有的希望都沒有消失。 有一種方法可以創建一個小VBS文件,可以在調用該VBS文件時運行任意QTP測試。 這比為每個測試創建單個批處理文件要好得多。

'*******************************************************************
'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 Path\\The Test Itself\\"

多線程驅動程序工具可以為您執行腳本。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM