Extending QC with Open Test Architecture (OTA) API Prepared by: Igor Gershovich
[email protected] www.connectedtesting.com
What is Quality Center Open Test Architecture (OTA) API? The Open Test Architecture API is a COM library that enables you to:
integrate external applications with Quality Center interact with the Quality Center application without having to use the GUI front-end interact with the QC databases bypassing DBA
QC Architecture 3-tier architecture (Web server, App server, DB server)
OTA API location The library, OTAClient.dll, is automatically downloaded to your workstation the first time you run Quality Center to the following folder:
\Program Files\Common Files\Mercury Interactive\Quality Center Alternatively, click the Add-ins page link, select Mercury Quality Center Client Side Setup, and click Download Add-in.
How to use OTA API? There are several ways to use OTA API: Add OTA code within QC Workflow scripts to extend Workflow capabilities Enhance Quality Center VAPI-XP tests Using the QCUtil object in QuickTest Pro Write a custom test execution program Read information from a QC for use by an external tool or report generator Integrate any third-party tool with QC
OTA Object model
API functions
The API functions are accessible through COM-compatible programming languages, such as Visual Basic, VBScript, C++, C#, etc. The API has one entry point - TDConnection object
Implementation examples
1. External program to schedule QC tests execution – RunTestSet.exe
Custom Test Execution program – RunTestSet.exe
Quality Center does not have a built-in testset scheduler to run tests periodically OTA API enables users to run external tool that can execute any testset on any host As example RunTestSet application (with VC++ source code) coupled with Microsoft Scheduler can be used to schedule tests
RunTestSet.exe command line syntax RunTestSet /s:Server /n:Domain /d:Project /u:User /p:Password /f:TestSetFolder [/t:TestSet] [/h:Host] | [/g:HostGroup] Where: /s: QC server name /n: QC Domain /d: QC Project /u: User name /p: User password /f: TestSet Folder Path /t: [optional] TestSet name /h: [optional] Host name /g: [optional] HostGroup name /m:[optional] QC User name who will receive execution event notification mail /l [optional] run TestSet locally Example : RunTestSet.exe /s:http://qcserver/qcbin /n:default /d:access /u:admin /f:Root\hello /t:WRScript /l
Schedule RunTestSet.exe execution
Execution Event Notification Email
2. Custom Reporting tool
Custom Reporting tool
This tool uses HTML and VBScript As an example, we are going to run custom queries against a Quality Center project The steps:
This tool connects to the project using OTA API Execute custom DB queries Displays results
Project Reporting tool
Reporting tool - Code snippet
OTA API TdConnection.Command object used to run Project DB queries
Sub CheckIntegrity Set cmd = TdConnection.Command TestIntegrity "SELECT * FROM BUG WHERE BG_SUBJECT NOT IN (SELECT AL_ITEM_ID FROM ALL_LISTS)", _ "defect(s) without subject (none expected)", 0 TestIntegrity "SELECT * FROM DESSTEPS WHERE DS_TEST_ID NOT IN (SELECT TS_TEST_ID FROM TEST)", _ "design step(s) without test (none expected)", 0 TestIntegrity "SELECT * FROM TESTCYCL WHERE TC_TEST_ID NOT IN (SELECT TS_TEST_ID FROM TEST)", _ "test(s) in test set without test in test plan (none expected)", 0 TestIntegrity "SELECT * FROM TESTCYCL WHERE TC_CYCLE_ID NOT IN (SELECT CY_CYCLE_ID FROM CYCLE)", _ "test(s) in test set without test set (none expected)", 0 TestIntegrity "SELECT * FROM STEP WHERE ST_RUN_ID NOT IN (SELECT RN_RUN_ID FROM RUN)", _ "step(s) without run (none expected)", 0 TestIntegrity "SELECT * FROM RUN WHERE RN_TEST_ID NOT IN (SELECT TS_TEST_ID FROM TEST)", _ "run(s) without test (none expected)", 0 TestIntegrity "SELECT * FROM RUN WHERE RN_CYCLE_ID NOT IN (SELECT CY_CYCLE_ID FROM CYCLE)", _ "run(s) without test set (none expected)", 0 TestIntegrity "SELECT * FROM REQ_COVER WHERE RC_REQ_ID NOT IN (SELECT RQ_REQ_ID FROM REQ)", _ "requirement coverage without requirement (none expected)", 0 TestIntegrity "SELECT * FROM REQ_COVER WHERE RC_TEST_ID NOT IN (SELECT TS_TEST_ID FROM TEST)", _ "requirement coverage without test (none expected)", 0 TestIntegrity "SELECT * FROM CYCLE WHERE CY_FOLDER_ID NOT IN (SELECT CF_ITEM_ID FROM CYCL_FOLD)", _ "test set(s) without test set folder (1 expected)", 1 Set cmd = Nothing End Sub
3. Enhancing QC Project Workflow
Workflow Script Editor
Modified Project_CanLogin function to block users without password
Login error for user without password
4. Using QTP QCUtil object to write to QC User-Defined fields
QTP script uses QCUtil object to write Flight Confirmation Number to QC RN_USER_01 and TC_USER_01 fields
Writing to QC Fields via QTP QCUtil object
TC_USER_01
RN_USER_01
5. VAPI –XP Script with OTA API
Create a new VAPI-XP test
Scripting languages for VAPI-XP script
VAPI-XP script storing Bug data to Excel spreadsheet
Bug data stored in Excel
Resources
HP Mercury Tools Specific weblog by Valery Raulet from Exposit Limited – http:// blogs.exposit.co.uk/ QA Forums – www.sqaforums.com HP/Mercury Quality Center Open Test Architecture API Reference
Igor Gershovich
E-Mail: [email protected] Phone: 720-933-9395 Website: www.connectedtesting.com