How to set up hudson and continuous testing – part 1

My plan was simple. It was almost the same plan as Selenium implementation using Maven. This time, the goal was to use QTP instead of Selenium, since most (well, almost all) of my teammates are more familiar with QTP that they are with the other tool.

Anyway, installing Hudson was simple enough.

Download hudson from here:

Then, follow the text from this link:
http://solitarygeek.com/java/hudson-ci-server-a-step-by-step-guide-part-i.

Here the text:
Installing Hudson is super easy. Just download the war file, open your terminal/command-prompt and issue the command “java -jar hudson.war”. Now point your browser to http://localhost:8080. That was easy, right?

Well, turned out, if I save the war file in some random places, i.e. C:/this is one folder/and this is another/hudson.war, the war file gives error when you issue the command.

Easy solution, save your war file in C:/hudson. It will finish installation.

Running Hudson would look like this:

hudson-startup

Here is how Hudson looks after loading first:
hudson-default

hudson-manage

Now, to run QTP, we can just google to find out the necessary VB code. I used this site:

http://madhuscribblings.wordpress.com/2010/09/23/hello-world/


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 = "Normal"
qtApp.Options.Run.ViewResults = True
qtApp.Open "E:\QTP_scripts\Admin_user_search", 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 = "E:\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 "E:\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 = "C:\Program Files\HP\QuickTest Professional\dat\PDetails.xsl"
sShortXSL = "C:\Program Files\HP\QuickTest Professional\dat\PShort.xsl"

ApplyXSL sResultsXML, sDetailedXSL, "E:\hudson\workspace\QTP-Hudson\Results_Detailed.html"
ApplyXSL sResultsXML, sShortXSL, "E:\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

To be continued …

Advertisement

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: