Upload
vuonghuong
View
214
Download
1
Embed Size (px)
Citation preview
www.assure.fi
Discover the possibilities of using the
Quality Center API
Shir Goldberg
11-Nov-2009
Release quality on time
www.assure.fi
Introduction
• HP (Mercury)
• Assure
• Quality Center Experience
www.assure.fi
Contents
• HP Quality Center
• What is QC API
• QC API – Structure and Objects
• Permission Management
• Different development / programming tools
• QC API & Reporting
• Solutions Developed using the QC API
www.assure.fi
HP Quality Center (QC)
• HP Quality Center is the world's leading solution for Application
Lifecycle Management
• Includes all the testing lifecycle from testing requirements, test
cases, test execution and defects
• Market leader with about 60% market share
• Essential tool for QA organizations
• Highly customizable
www.assure.fi
What is QC API
• A programmatic interface to QC, Implemented as a COM object
• Gives access to virtually all the entities in QC
− Requirements
− Releases and Cycles
− Test Cases
− BPT
− Test Sets
− Runs
− Defects
− Customization
• Limitations:
− Only works on windows
− Not thread safe
www.assure.fi
QC API - Structure
• General structure
TDConnection
• Factory - Get list of items, add items, create
relationships, etc
• Customization - users, user-groups, fields,
lists
• 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
www.assure.fi
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.
• 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
www.assure.fi
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
• 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
www.assure.fi
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 themWhile Not recset.EOR
Dim 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.Post()
recset.Next()
Wend
www.assure.fi
QC API – Permission Management
• QC API works under the same permissions 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
www.assure.fi
QC API & QC Workflow
• QC Workflow
− Project 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:
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
www.assure.fi
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
www.assure.fi
QC API - VBA
• VBA is used in Microsoft Office tools (macros). Very useful to
bring data from QC to Excel for example.
• Better 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
www.assure.fi
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 Bridge
• Solutions 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
www.assure.fi
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?
• 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
www.assure.fi
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
• Trash-Bin
• Test Data management and inheritance solution
www.assure.fi
QC API – Combined workflow / COM solution
Workflow
Workflow Event
obj = CreateObject(“my.control”)
obj.Set_QC_Connection(TDConnection)
obj.ProcessTest(TestID)
My Control
TDConnection
Obtain the Test
object from the
ID
Manipulate Test
……
……
……
www.assure.fi
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
www.assure.fi
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
• Web-Service wrapper for QC API
• Use QC data and API on all 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
www.assure.fi
QC API - solutions developed
• Test Data solutions
• Localization
• Test Data Inheritance
www.assure.fi
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
www.assure.fi
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
www.assure.fi
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
www.assure.fi
Questions?
Bo Strøm – Wistmo
Shir Goldberg - Assure
http://www.assure.fi
• Some of the solutions presented are available as products from Assure