DISCOVER THE POSSIBILITIES OF USING THE HP QUALITY CENTER API
Presentation for the VIVIT TQA SIGPresentation for the VIVIT TQA SIG
By Olli Laiho and Shir Goldberg
Assure
May 12th 2010
Release quality on time
About us
Olli Laiho
VIVIT TQA SIG Leader
QC Consultant and Trainer
Shir GoldbergShir Goldberg
Experienced QC Developer and Architect
Release quality on time
Introduction
HP (Mercury)
Assure
QC Experience
About this presentation
It’s gonna be fairly technical
Concepts at the end
Q&A at the end
QC API
A programmatic interface Quality Center, Implemented as a COM object
Gives access to virtually all the entities in QC
Requirements
Releases and Cycles
Test CasesTest Cases
BPT
Test Sets
Runs
Defects
Customization
Limitations:
Only works on windows
Not thread safe
QC API
General structure
TDConnection
• Factory - Get list of items, add items, create
relationships, etc
• Customization - users, user-groups, fields,
lists
• Others – Command, Settings and more…• Others – Command, Settings and more…
ReqFactory
BugFactory
TestFactory
…Factory• Where to find information about the QC API
− QC Documentation
− HP support pages and discussion groups
− Internet forums
Settings
Customization
…
Command
QC API – the Settings object
• There are two types of Settings object in QC:
• Common Settings – visible to all users in a project
• User Settings – storing user specific data
• These objects are very useful for storing data in a project. You can
read and write to the settings and add your own setting categories
and values.and values.
• Values stored in the settings are saved to the QC database and are
available thereafter
function RecordLoginTime
set sett = TDConnection.UserSettings
sett.Open "Login"
sett.value("Last Login Time") = cstr(TDConnection.ServerTime)
sett.close
set sett = nothing
end function
QC API – the Command object
• This object enables execution of SQL commands via the API• Pros:
• Excellent for getting data quickly• Good for getting a lot of information quickly• Good for reporting
• Cons• Cons• No filtering on the commands – drop, delete etc are all
allowed• By default – only TDAdmin can use this object• If enabled for other users – fully works for ALL users
QC API – the Command object -Sample
’get all tests under a folder...
query = "SELECT TS_TEST_ID FROM TEST WHERE TS_SUBJECT = '" & CStr(myNode.NodeID) & "'"
Set cmd = TDConnection.Command
cmd.CommandText = query
Set recset = cmd.Execute()
'go through all the test cases, rename and move them
While Not recset.EOR
Dim tf 'As TestFactoryDim tf 'As TestFactory
Dim MyTestCase 'As Test
Set tf = myNode.TestFactory
Set MyTestCase = tf.Item(recset.FieldValue(0))
MyTestCase.Field("TS_STATUS") = "Deleted"
MyTestCase.Field("TS_SUBJECT") = otherNode.NodeID
MyTestCase.Field("TS_NAME") = MyTestCase.Field("TS_NAME") & " - moved"
MyTestCase.Post()
recset.Next()
Wend
QC API – Permissions
QC API works by the same permission of the
TDConnection it uses
Example: If the user has no rights to delete defects – it will not be possible for this user to delete defects via the API. An error will be returned from the API ”insufficient permissions”
This is the same for a stand alone application or code that is invoked from the workflow
The Command object is an exception – if it is enabled any SQL can be executed by anyone
QC API & QC Workflow
QC WorkflowProject Specific
Used to implement business rules, additional functionality
Gives access to the API via the TDConnection object
Example - Get a list of the covering test cases of a requirement when we click on it:when we click on it:
i=0
set req =
TDConnection.ReqFactory.Item(Req_Fields("RQ_REQ_ID").Value)
set testList = req.GetCoverList(true)
for each tst in testList
if tst.Field("TS_RESPONSIBLE") = TDConnection.username then
i = i + 1
end if
next
Req_Fields("RQ_USER_11").Value = i
QC API - VBScript
VBScript scripts are good for maintenance tasks or
scheduled updated / extraction of data
Pros:
• No development env. needed
• Can be executed very easily
Cons:
• No real UI
• Scripting language is limited
• Limited debugging mechanism
QCDefects.vbs.txt
QC API - VBA
QC API is called from VBA – VB for Applications:
VBA is used in Microsoft Office tools (macros). Very
useful to bring data from QC to Excel for example.
Better development environment than VBScriptBetter development environment than VBScript
Can build UI – such as forms
Sample solutions:Reporting
Cross-Project User Management
Import / export from QC (HP supplies such import tool)
Extract of entities from QC
Extract of Project structure
Extract of Project Groups
QC API - C++/C#/VB.NET/Java
Offers full use of the QC API
Complete programming IDE and languages
Stand alone solutions
Java – needs a Java-COM BridgeSolutions Developed:
Asset Sharing
Reporting
Test Set creation Wizard
Requirement Coverage Wizard
Integrations
QC Web Service – a WS wrapper to QC API
Admin Console for QC
QC API – Combined workflow / COM solution
That’s the way to bring the real programming solution into QC itself
and use it from inside the QC UI
• Add your own UI to QC where needed
• Implement complex logic easily
How does it work?How does it work?
• Create a COM object with the methods you want to call from the
QC workflow
• Make sure you have a method that will get the TDConnection
object from the workflow• Create the object in the workflow using the CreateObject method
• Pass the TDConnection object from the workflow to your COM
object
• Call any other method of the COM object from the workflow as
necessary
QC API – Combined workflow / COM solution
Solutions Developed:
• Localization of test cases – localization values come from an
external DB via a web service
• Implementing linking rules when linking failed runs to existing
defects – linking can be done to matching defects only
• Integration for bringing list values from external systems• Integration for bringing list values from external systems
• Trash-Bin
• Test Data management and inheritance solution
QC API – Combined workflow / COM solution
Workflow
Workflow Event
obj = CreateObject(“my.control”)
obj.Set_QC_Connection(TDConnection)
obj.ProcessTest(TestID)
My Control
TDConnection
Create Test from the ID
Manipulate Test…… Manipulate Test………………
QC API – Reporting
• Reporting can be done with the API – BUT:
• Iterating through many items with the API is very slow
• It might cause performance problems
• The better option is to use the Command object
• Security Risk to enable it to all the users
• Performance issues if very large and complex queries are used• Performance issues if very large and complex queries are used
QC API - solutions developed
• Asset sharing between projects
• Sharing of test cases and requirements between QC projects
• Feature /customization management
• A utility that enables configuration management across QC
projects
• Many different approval and life-cycle solutions• Many different approval and life-cycle solutions
• Web-Service wrapper for QC API
• Use QC data and API across platforms by using web services
• Offline client
• Execute test cases while on the go. Report the results when
back in Office
• Copying requirements with their coverage information
QC API - solutions developed
• Test Data solutions
• Localization
• Test Data Inheritance
QC API - solutions developed
• Wizard for test case selection
• Select test cases for execution or requirement coverage.
• Selection is based on any filter or link between QC entities.
• E.g. create a test set with all test cases that have failed for a
specific release and have open defects
• Trash Bin• Deleted items go to a trash-bin• Deleted items go to a trash-bin
QC API - solutions developed
• Harmonization Solution for QC Projects - Make sure your QC
projects have the same fields in place. Enables:• Company wide testing language and processes
• Company wide reports – same meaning on all QC projects
• Asset sharing is possible
• Integrations are much simpler
QC API - solutions developed
• Admin Console – multi-user-project-operations• Adding user to multiple groups on multiple projects at once
• List management across projects
• Copying groups across projects
QC – What’s hot
HP Agile Accelerator
”The Future of Testing” blog by Roi Carmel / HP
TDForums.com
Advancedqtp.com
HP Software Universe 2010 in Washington
twitter.com/HPSoftware
twitter.com/HPSWU
twitter.com/assureqc
Release quality on time
Summary
QC API is flexible and enables a variety of
customizations
Everything from small workflow features to stand-alone tools, integrations and reporting solutions
Enables you to fulfill the business needs of your usersEnables you to fulfill the business needs of your users
Control your customizations – develop them in a
centralized team, have a release process for them,
manage how they are deployed into projects