Tuesday, August 28, 2012

ALM / QC integration using OTA API

To integrate your test automation tools with HP Quality Center / Application Lifecycle Management, the easiest way is to use QC's Open Test Architecture (OTA) API.

OTA API is a COM library that enables you to integrate external applications with QC. Through this interface you can do most of the same tasks as you can do through the GUI.

To be able to access OTA API from your PC, you have to install the HP Quality Center Connectivity Add-in. To do so, go to Help -> Add-ins page and select HP Quality Center Connectivity. It will download the OTAClient.dll to your PC.

Here is an example script in Ruby, which counts the amount of open defects in QC:

require 'win32ole'

opendefects = 0

# Create the TDConnection object
qc = WIN32OLE.new('TDApiOle80.TDConnection')

qcserver = 'http://localhost:8080/qcbin/'

# Initiate connection to the QC server
qc.InitConnectionEx(qcserver)                     
puts "Connection status: #{qc.Connected}"                         

# Authenticates to QC
qc.Login("myuser", "mypassword")                      
puts "Logged in status: #{qc.LoggedIn}"

# Connect to the QC Domain and Project
qc.Connect("MYDOMAIN", "myproject")                 
puts "Project Name: #{qc.ProjectName}"

# Get defect list and count open defects
bugf = qc.BugFactory
bugl = bugf.NewList("")

for thisBug in bugl
    if thisBug.Status == "New" or thisBug.Status == "Open" or thisBug.Status == "Reopen"
        opendefects = opendefects+1
    end
end

# Disconnect and Logout from QC
qc.Disconnect
qc.Logout
puts "Logged in status: #{qc.LoggedIn}"

# Release connection from the QC server
qc.ReleaseConnection
puts "Connection status: #{qc.Connected}"

# Print results
puts "Total number of defects: " + bugl.count.to_s
puts "Total number of open defects: " + opendefects.to_s



... and the output should be something like:

Connection status: true
Logged in status: true
Project Name: myproject
Logged in status: false
Connection status: false
Total number of defects: 52
Total number of open defects: 5

1 comment:

  1. How to update result in qc after test execution?
    Please please help me.

    ReplyDelete