Importing automated test results to HP QC/ALM

december 3rd, 2013


HP QC or ALM is used by many organizations to manage quality assurance, and often the whole application life cycle. HP QuickTest Professional (which is shipped in the HP Unified Functional Testing package with HP Service Test) is integrated with QC/ALM out of the box, but other technologies like JUnit tests, Selenium tests and others often require custom solutions to integrate with QC/ALM.

HP Open Test Architecture

One solution is to use the Open Test Architecture API to interact with QC/ALM, this is a COM library provided by HP. It comes with the QC/ALM Client installation. The API provides functionality to interact with most parts of a QC/ALM project, like defects, requirements and tests. Since it is a COM library it works naturally with Visual Basic, and also with VBScript. I will be using VBScript and HP ALM in the following examples. If you are using QC some directions for the web client may not be correct, but they should be similar enough to be followed.


To work with the OTA COM library from VBScript the dll-file has to be registered with Windows, this is most conveniently done by logging into QC/ALM using a browser, when logged in go to Help -> Add-ins page. Chose HP ALM Registration, read the list of requirements for the Client registration and make sure that all requirements are fulfilled. Then at the bottom of the page click Register HP ALM Client. A successful registration of the client is required to continue with the examples below..

A working knowledge of VBScript or Visual Basic is also required to follow the examples provided in this post.

TDConnection - Connecting to ALM/QC

The following code shows how to make a connection to a QC/ALM project.

Public Function ConnectToQC(ByVal server, ByVal Domain, ByVal Project)
Dim QCServer, UserName, Password, QCConnection
QCServer = server & "/qcbin"
UserName = "<qc username>"
Password = "<qc password>"

Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx QCServer
QCConnection.login UserName, Password
QCConnection.Connect Domain, Project

Set ConnectToQC = QCConnection
End Function

Dim QCConnection
Set QCConnection = ConnectToQC("http://qcservername:8080", "TEST_DOMAIN", "TEST_PROJECT")

The QC user must have the proper permissions to execute the actions in the script, just like when using the web client.

Interacting with QC/ALM objects

To create objects from the COM library, the QCConnection object created in the first code example can be used, for example to create a test instance object from a test instance in QC. The following code example is a modified example from the OTA API reference, in the reference the examples are written in Visual Basic 6.0, I have modified the following code to VBScript and changed it to comply with my requirements.

Dim TestSetFact
Dim TSTestFact
Dim theTestSet
Dim theTSTest
Dim TestSetTestsList
Dim TestSetsList
Dim tsTreeMgr
Dim tSetFolder
Dim QCConnection
Set QCConnection = ConnectToQC("http://qcserver:8080 ", "TEST_DOMAIN", "TEST_PROJECT")
Set tsTreeMgr = QCConnection.TestSetTreeManager

' Get the TDConnection.TestSetFactory.
Set TestSetFact = QCConnection.TestSetFactory
' Get the test set tree manager from the test set factory.
Set tsTreeMgr = QCConnection.TestSetTreeManager
' Get the test set folder.
Set tSetFolder = tsTreeMgr.NodeByPath("Root\Test Set Folder")
' Because we are searching for the full name,
' the list will have only one entry.
Set TestSetsList = tSetFolder.FindTestSets("Test Set 1")
Set theTestSet = TestSetsList.Item(1)
' Get the test set attributes.
Wscript.Echo "Test Set ID = " & theTestSet.ID & ", Name = " _
& theTestSet.Name & ", TestSetFolder = " & theTestSet.TestSetFolder
' Get the TSTest factory and list of TSTests.
Set TSTestFact = theTestSet.TSTestFactory
Set TestSetTestsList = TSTestFact.NewList("")

For Each theTSTest In TestSetTestsList
i = i + 1: If i > 10 Then Exit For
With theTSTest
Wscript.Echo "TSTest Name: " & .Name, "ID: " & .ID, _
"TestID: " & .testID, "Instance: " & .instance
sID = theTSTest.ID 'Save the last ID
End With

This example code will create a TestSet object and a list of TSTest objects and display some of their properties.

To change a property of an object set it directly to a new value and then post it to the QC/ALM server, example:

Dim firstTestInTestList
Set firstTestInTestList = TestSetTestsList.Item(2)
firstTestInTestList.Status = "Failed"

Closing the connection

The last step of the script should be to clean up the connection.



Working with the OTA API is pretty straight forward and can have very useful real life applications. If an applications quality assurance is tracked using QC/ALM then integration between test automation and QC/ALM is, in my opinion, necessary to facilitate a smooth work flow.

For further reading on the subject see the OTA API reference, the reference is available from the QC/ALM web client.

Frank Lindholm Okategoriserade

Setting up SFTP on an Amazon Windows 2008 EC2 Instance

september 11th, 2012

I wanted to be able to transfer files to an Windows 2008 EC2 instance, but I found the file transfer abilities in RDP to be a bit unreliable. I then started thinking about setting a SFTP server on the EC2 instance. I just wanted a light weight SFTP solution and therefor I chose to use Core FTP mini sftp server on the server side (EC2 instance) and WinSCP as the client.

The first step is to edit the security group in the EC2 management console to allow traffic on port 22, make sure that it is the same security group that your instance is using.

The second step is to edit the firewall settings in Windows 2008, open Server Manager -> Configuration -> Windows Firewall… -> Inbound rules -> New Rule. In the Wizard chose Port, TCP as protocol, Specific ports “22″, Allow the connection (for higher security study the IPsec configuration and user Allow the connection if it is secure), give the rule a name and finish the wizard.

Transfer the mini sftp server to the EC2 instance using RDP file transfer. Start the server and fill in username, password and root path, make sure the root path points to a directory where the System user have write and modify rights.

Use the public DNS as to connect with WinSCP to the mini sftp server, using the username and password specified in the previous step.

Frank Lindholm EC2, SFTP ,

Selenium - Web application testing system

mars 5th, 2009

When I have had the need for a testing system for web applications I have always used httpunit, which is very good and it has given me all the functionality that I’ve ever needed. A couple of weeks ago my boss hinted about Selenium, and as a developer with a lot of experience with web development it of course got me curious. I downloaded it and tried it out.

The first thing I noticed was that the GUI was pretty simple and straightforward, when Selenium is started from Firefox it assumes that the current page is the page that is should run its test cases on. If it is not, just change the “Base url” at the top of the GUI to the correct Url.  The recording is also started immediately and the user can start adding actions to the test case, this is done mainly by right-clicking on the web page and choosing from the different options, for example you can mark a portion of text and choose verifyTextPresent, after this the test action is shown the main window.

To run a test case or test suite, just click the recording button to stop recording and then on of the two play buttons.

There are two tabs, Table and Source, when clicking on the tab Source by default the source is shown as html, but as a Java programmer I would rather use JUnit to run Selenium test cases. Under Options -> Format it is possible to chose from a number of languages, as Java, C#, Perl and more. When a format other than html is chosen the “Table” tab is inactivated and also the run commands are inactivated. To use the generated code, in my case Java code, first the proper JUnit packages must be in the projects classpath. I use Eclipse so I just add the junit.jar to my Java Build Path. Then the Selenium packages. Then finally before executing the class that extends SeleneseTestCase the selenium server must be started. I didn’t need to configure anything to make the server work, just started it from my terminal, very good!

When running the test case or test suite Selenium opens firefox, very disappointing but it is not hard to see why they went this route. Httpunit has all the parsers and connectors it need to take care of the http requests and responses, selenium seems to piggy back on Firefox. This is not disaster, but it is slow. Selenium has to fire up firefox as a new process then run the test cases in a local web page with frames. After the test case or suite has been executed the results are reported in Junit as expected.

Overall Selenium works quite nice although slow when using it with Junit, and I was able to simulate user login and other user behaviour and assert the outcome with it, both from the GUI and from Junit.

Frank Lindholm Testing