2016-11-15 9 views
0

私はJenkinsとQTP 10.0を統合しました。私はJenkinsからテストスクリプトを実行することができます。私が直面している問題は、QTP出力結果がJenkinsコンソールに表示されないということです。私は、単純なHTMLファイルを作成し、テストを実行し、コンソール&で結果が表示されますサンプルランナーファイルを作成していたJenkinsとQTP 10.0の統合

Dim App,strDrive, strfoldername,objFSO, objFolder, strPath, TestScriptpath1, oFSO 


' Launch QuickTest Professional and make it visible. 
Set App = CreateObject("QuickTest.Application") 
Set qtResultsObj = CreateObject("QuickTest.RunResultsOptions") 
Set fsobj=CreateObject("Scripting.FileSystemObject") 
Set xlApp = CreateObject("Excel.Application") 
Set xlBook = xlApp.WorkBooks.Open("C:\Batch File\QTP_Scripts.xls") 
Set xlSheet = xlBook.WorkSheets("Sheet1") 
'Set stdout = fsobj.GetStandardStream (1) 
'stdout.WriteLine "This will go to standard output." 

Set WshShell = CreateObject("WScript.Shell") 


App.Launch 
App.Visible = True 
strfoldername="_Result" 

'Read all the Test path from the Excel and Loop through all the tests. 
For ix = 2 To xlSheet.UsedRange.Rows.Count 
    TestScriptpath = xlSheet.Cells(ix, 1).value 
    TestScriptpath1=Split(TestScriptpath, "\") 

    'Open the test in QuickTest Professional. 
    App.Open TestScriptpath,True,False 


    'Create Environment Variables to pass the results from QTP to runner.vbs 
    APP.Test.Environment.Value("JenkinsFlag") = "Y" 
    APP.Test.Environment.Value("JenkinsTestCaseDescription") = TestScriptpath1(2) 


    sResultFolderPath="C:\BUILD_TAG\" 
    '' Get the test object. 
    Set qtTest = App.Test 
    ResultFolderPath1=sResultFolderPath&TestScriptpath1(2)&strfoldername 
    Set objFolder = fsobj.CreateFolder(sResultFolderPath1) 

    'Execute the test. Instruct QuickTest Professional to wait for the test to finish executing. 
    'This statement specifies a test results location. 
    qtResultsObj.ResultsLocation=sResultFolderPath1 
    qtTest.Run qtResultsObj, True 
    StrResult=qtTest.LastRunResults.Status 
    xlSheet.Cells(ix, 2).value=StrResult 


    'Write the result in the console 
    While APP.Test.isRunning 
     If APP.Test.Environment.Value("JenkinsFlag") = "Y" Then 
      'APP.Test.Environment.Value("JenkinsFlag") = "N" 

      ' Show TC ID and Description 
      WshShell.StdOut.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription")&TestScriptpath1(2) 
      'stdout.WriteLine APP.Test.Environment.Value("JenkinsTestCaseDescription") &TestScriptpath1(2) 


      'Wait till the test is executed & result is updated 
      While (APP.Test.Environment.Value("JenkinsTestCaseResult") = Reporter.runstatus AND APP.Test.isRunning) 
       WshShell.Sleep 1000 
       'stdout.Sleep 1000 
      Wend 

      'Show the Result 
      WshShell.StdOut.Write APP.Test.Environment.Value("JenkinsTestCaseResult") 
      'stdout.Write APP.Test.Environment.Value("Jenkins TestCaseResult") 
     End If 
     WshShell.Sleep 1000 
     'stdout.Sleep 1000 
    Wend 

    ' Close the test. 
    qtTest.Close 
Next 
xlApp.ActiveWorkbook.Save 
xlApp.ActiveWorkbook.Close 

App.Quit 
xlApp.Quit 

If Not xlApp Is Nothing Then 
    xlApp.Quit 
    Set xlApp = Nothing 
End If 

'Release the created objects. 
set qtResultsObj = nothing 
set fsobj= nothing 
set qtTest = nothing 
set App = nothing 
set xlApp = nothing 
set xlBook = nothing 
set xlSheet= nothing 
+0

どのようにこのスクリプトを実行していますか?どのビルドタスクを選択しましたか? –

答えて

関連する問題