Monday, March 15, 2010

OTA, an API for extending Quality Center

Quality Center API
The manipulation API is called Quality Center API and allows the interaction with Quality Center.

It also allows you to interact with the database through the API making the interactions more secure. Also, it avoids your DBA (DataBase Administrator) having to provide an access to the database server(s) hosting the Quality Center database(s).The API has only 1 entry point which is the TDConnection object. From this object, you can access a lot of Quality Center functionalities. The API functions are accessible through VBScript and any COM aware programming languages. It means that you can use this API as a standalone .VBS application, a macro in an Excel file, a script in QuickTest Professional or any other application where you would like to integrate such functionalities.As an example, we are going to download all the defects that are stored on a Quality Center project using the Excel application.The steps involve:
Connect to the project Run a query to retrieve a list of defects Store the result in an Excel worksheet

1. Connect to the project:
Each project stored in a Quality Center server is identified by its pair Domain/Project and a project is accessible only if the user belongs to this project. The connection to a server can be done by using only 4 lines of code:Dim QCConnection‘ Return the TDConnection object.Set QCConnection = CreateObject(“TDApiOle80.TDConnection”)QCConnection.InitConnectionEx “http:///qcbin”QCConnection.login “”, “”‘ DEFAULT = Domain, QualityCenter_Demo = ProjectQCConnection.Connect “DEFAULT”, “QualityCenter_Demo”

2. Execute a query:
To execute a query in Quality Center, you have several options available.The first one is to use the Command object. This object can run SQL queries for any Quality Center table. However, you need to be aware of what table to query and make sure you know what you do because you can mess up Quality Center. Also, this Command object can be used only if you are part of the TDAdmin group in this project.The second one is to use a Factory object. The factory object returns objects that are part of the API, restricting the user from making mistakes. This is the method we’ll be using in this article. To access the defects, we are using the BugFactory:Dim BugFactory, BugListSet BugFactory = QCConnection.BugFactorySet BugList = BugFactory.NewList(“”) ‘ Get a list of all the defects.

3. Store the result in an Excel worksheet:
We assume that you are running this script from a VBS file. Consequently, we have to open Excel first, then store the data in an Excel worksheet:

Dim Bug, Excel, Sheet
Set Excel = CreateObject(“Excel.Application”) ‘ Open Excel
Excel.WorkBooks.Add() ‘ Add a new workbook
‘ Get the first worksheet.
Set Sheet = Excel.ActiveSheetDim Bug, Row
Row = 1
‘ Iterate through all the defects.
For Each Bug In BugList
‘ Save a specified set of fields.
Sheet.Cells(Row, 1).Value = Bug.Field(“BG_BUG_ID”)
Sheet.Cells(Row, 2).Value = Bug.Summary
Sheet.Cells(Row, 3).Value = Bug.DetectedBy
Sheet.Cells(Row, 4).Value = Bug.Priority
Sheet.Cells(Row, 5).Value = Bug.Status
Sheet.Cells(Row, 6).Value = Bug.AssignedTo
Row = Row + 1
Next‘ Save the newly created workbook and close Excel.
Excel.ActiveWorkbook.SaveAs(“c:\QualityCenter_Demo_DEFECTS.xls”)
Excel.Quit

3 comments:

Dinesh said...

Hi

I have established the comnnections to QC from ASP.net. Everything was fine. But when i host it on IIS. I could connect. PLease help..


Regards,
Dinsh K
001 416 567 5164

Dinesh said...
This comment has been removed by the author.
Unknown said...

Java code to connect QC database using OTA

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory