我们有一个使用 HP Quality Center 的项目,我们面临的常见问题之一是人们没有更新对缺陷的评论。
所以我在想,如果我们能想出一个小脚本或工具,可以用来定期发出提醒并强制用户更新评论。
我遇到了 Open Test Architecture API,想知道是否有我能看到的任何好的 Python 或 Java 示例。
谢谢 哈里
最佳答案
使用 Python (win32com) 通过 OTA 连接到 HP Quality Center 的示例
HP Quality Center 公开了一个名为 OTA 的基于 com 的 API。
有关此的文档可从 QC 服务器下载 (OTA_API_Reference.chm)(奇怪的是网上很难找到)
文档使用 VBScript(QC 官方支持的内部语言) 并且您需要在头脑中将其转换为 Python。这通常很简单,但是 存在一些问题。
您需要在您的计算机上安装 Quality Center 本地代码,这是在您的 Windows PC 上 如果您能够通过 Web 界面访问 QC。
您还需要知道服务器的 URL 以及您的用户名和密码以及域 您正在从事的 QC 项目。
from win32com.client import Dispatch
conn = get_QCConnection()
for bug in get_bugs(qcConn):
print bug.Title
put_QCConnection(conn)
#below code needs to be in seperate module or at least above the fold but here
# for clarity
def get_QCConnection():
'''Get the hardcoded connection to the server and domain.
Can be made a "real" engine if you try hard.
Use makepy utility to determine if the version number has changed (TDApiOle80)
but this works to current version'''
QCConnection = Dispatch("TDApiOle80.TDConnection")
url = "http://qc.example.com/qcbin"
QCConnection.InitConnectionEx(url)
QCConnection.login("USER", "PASS")
QCConnection.Connect("google_projects", "Google_Chrome")
return QCConnection
def put_QCConnection(qcConn):
#If one person logged in to QC changes *anything* on a bug,
# they hold a global lock on writing to that bug till
# thier session times out, so really really remember to logout
# its painful to wait for your own session to time out
qcConn.Logout()
def get_bugs(qcConn):
'''just following boiler plate from vbscript
PS the SetFilter is not in QTA API, it uses Filter.
But due to the workarounds in
the very brilliant pythoncom code it supplies a virtual wrapper class
called SetFilter - this is one of those gotchas '''
BugFactory = qcConn.BugFactory
BugFilter = BugFactory.Filter
BugFilter.SetFilter(u"Status", "New")
#NB - a lot of fields in QC are malleable - and vary from site to site.
#COntact your admins for a real list of fields you can adjust
buglist = BugFilter.NewList()
return buglist
这对于继续前进来说是一个不错的基础,但是我为缺陷创建了一个虚拟类并运行如下内容:
dfcts = [defect(b) for b in buglist]
然后我可以将工作代码放入缺陷类并使事情变得更整洁。 您要做的一件事是继续访问 python 包装类内部的原始 qc 错误。
关于java - 使用 Python 或 Java 自动化 HP Quality Center,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2627419/