Let's see what i learned today. I tried setting up Hudson in my machine and integrated QTP with it to run the tests and generate the report in the Hudson . Then i used the below vbscript to trigger the QTP via Hudson . I didn't write the below script got the bits thru Google and modified it to fit my need. Yeah the script went fine and it generated the result in HTML format. So i used the HTML publisher plug-in in Hudson to view the reports in Hudson.
Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim qtTest 'As QuickTest.Test ' Declare a Test object variable
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start QuickTest
qtApp.Visible = False ' Make the QuickTest application visible
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = True
qtApp.Open "C:\hudson\workspace\QTP-Hudson\Test1", True ' Open the test in read-only mode
' set run settings for the test
Set qtTest = qtApp.Test
qtTest.Settings.Run.OnError = "NextStep" ' Instruct QuickTest to display dialog box
qtTest.Settings.Run.ObjectSyncTimeOut = 30000 'Instruct QuickTest to wait for 30 seconds for response
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object
'qtResultsOpt.ResultsLocation = "C:\hudson\workspace\QTP-Hudson\General_results" ' Set the results location
qtTest.Run qtResultsOpt ' Run the test
' Save the Run-time Data
qtApp.Test.LastRunResults.DataTable.Export "C:\hudson\workspace\QTP-Hudson\Runtime.xls" ' Save the run-time Data Table to a file
WScript.StdOut.Write "Status is:" & qtTest.LastRunResults.Status & vbCr & vbLf ' Check the results of the test run
WScript.StdOut.Write "Error is:" & qtTest.LastRunResults.LastError & vbCr & vbLf ' Check the most recent error
WScript.StdOut.Write "Result path is:" & qtTest.LastRunResults.path & vbCr & vbLf
sRespath = qtTest.LastRunResults.path
sResultsXML = "" & sRespath & "\Report\Results.xml"
sDetailedXSL = "D:\Program Files\HP\QuickTest Professional\dat\PDetails.xsl"
sShortXSL = "D:\Program Files\HP\QuickTest Professional\dat\PShort.xsl"
ApplyXSL sResultsXML, sDetailedXSL, "C:\hudson\workspace\QTP-Hudson\Results_Detailed.html"
ApplyXSL sResultsXML, sShortXSL, "C:\hudson\workspace\QTP-Hudson\Results_Short.html"
Public Function ApplyXSL(ByVal inputXML, ByVal inputXSL, ByVal outputFile)
sXMLLib = "MSXML.DOMDocument"
Set xmlDoc = CreateObject(sXMLLib)
Set xslDoc = CreateObject(sXMLLib)
xmlDoc.async = False
xslDoc.async = False
xslDoc.load inputXSL
xmlDoc.load inputXML
outputText = xmlDoc.transformNode(xslDoc.documentElement)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set outFile = FSO.CreateTextFile(outputFile,True)
outFile.Write outputText
outFile.Close
Set outFile = Nothing
Set FSO = Nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing
Set xmlResults = Nothing
End Function
qtTest.Close ' Close the test
qtApp.Quit ' Exit QuickTest
Set qtResultsOpt = Nothing ' Release the Run Results Options object
Set qtTest = Nothing ' Release the Test object
Set qtApp = Nothing ' Release the Application object
No comments:
Post a Comment