2010-04-13 5 views
7

우리는 HP Quality Center를 사용하는 프로젝트를 가지고 있으며 우리가 직면 한 정기적 인 문제 중 하나는 결함에 대한 의견을 업데이트하지 않는 사람들입니다.Python 또는 Java로 HP Quality Center 자동화

주기적으로 미리 알림을 표시하고 사용자가 코멘트를 업데이트하도록 사용할 수있는 작은 스크립트 또는 도구를 생각해 낼 수 있다면 생각했습니다.

Open Test Architecture API를 접했고 내가 볼 수있는 것과 동일한 Python 또는 Java 예제가 있는지 궁금합니다. OTA 직접 자바에 의해 소비 될 수 없기 때문에

감사 하리

답변

5

나는 JIntegra 같은 COM bridnge에 자바를 필요로, 자바에 대한 좋은 예제가 확실하지 않다.

파이썬에 대해서, 잘 당신은 Python COM API를 사용할 수 있습니다. 그리고 나서 모든 OTA 예제가합니다. OTA의 QC 문서가 충분히 있습니다.

하지만 여기서 진정한 질문은 파이썬이나 자바로 왜하고 싶은지입니다. Workflow 기능을 사용하여 QC에서 직접 필요한 것을 작성하지 않는 것이 좋습니다. 그러면 VBScript에서 논리를 작성하고 사용자 작업에 대한 QC UI 내에서 호출하도록 할 수 있습니다. 예를 들어 Defect/Bug의 Post 이벤트에 바인드하여 주석이 있는지 그리고 사용자에게 메시지를 직접 프롬프트하지 않는지 확인할 수 있습니다.

+0

감사합니다. VBScript 옵션을 사용해보고 어떻게 진행되는지 살펴 보겠습니다. – Hari

0

스크립트를 실행할 수있는 새 테스트 및 선택 유형 (VPXP_API)을 사용할 수 있습니다. 여기서 좋은 점은 문서에 많이 의존하지 않고 QC 내에서 드래그 할 수 있도록 함수 정의를 준비 할 수 있다는 것입니다. Python에서 구현 된 일부 스크립트를 QC 내에서 API를 사용하여 실행했지만 결과 (출력) 등을 직접 가져 오는 QC 테스트를 통해 구현했습니다. 일부 쉘 명령을 통해 어떤 스크립트를 호출 할 수 있습니다 모든 서버 등 ... 파이썬을 사용

+0

VPXP_API (VAPI_XP_TEST)를 사용하는 방법에 대한 자세한 정보를 원합니다. OTAClient를 Python 및 C#과 함께 사용했지만 품질 테스트를 위해 내 테스트 (예 : 셀레늄)를 실행하는 것은 여전히 ​​저를 피합니다. – fijiaaron

12

예 (win32com) HP 품질 센터 OTA라는 COM 기반의 API를 노출

OTA

를 통해 HP 품질 센터에 연결합니다. 이에

문서는

문서는 VBScript를 (QC에 대한 공식적으로 지원 내부 언어)를 사용 (이상하게이 온라인으로 찾을 매우 어려운)는 품질 관리 서버 (OTA_API_Reference.chm)에서 다운로드 당신은 것입니다 정신적으로 파이썬으로 번역해야합니다. 이것은 보통 매우 간단하지만, 두 개의 gotchas가 존재합니다.

품질 센터 로컬 코드를 컴퓨터에 설치해야합니다.이 컴퓨터는 웹 인터페이스를 통해 QC에 액세스 할 수있는 경우 Windows PC 에 있습니다.

사용자 이름과 암호 및 작업중인 QC 프로젝트의 도메인도 알고 있어야합니다.

dfcts = [defect(b) for b in buglist] 

은 그 때 나는 결함 클래스로 작업자 코드를 삽입 할 수 있고 깔끔한 일을 계속 :

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  

그러나 이것은 내가 결함 더미 클래스를 생성하고 같은 것을 실행, 향후에 대한 나쁜으로하지 않습니다 . 파이썬 래퍼 클래스 내부의 원시 qc 버그에 대한 액세스를 유지하기를 원한다.

+0

안녕하세요. 답변에 감사드립니다. 그것은 좋은 출발점입니다! 그러나이 인터페이스에 대한 일종의 참조 (문서)가 있는지 알고 싶습니다. –

6

이 스레드를 볼 수있는 사람들의 정보입니다. 여기에서 http://sourceforge.net/projects/pywin32/files/pywin32/Build216/

당신은 pywin32를 가져와야합니다 모든

먼저 다음

'''@author: www.qcintegration.com @mailto:[email protected]''' 
import pywintypes 
import win32com.client as w32c 
from win32com.client import gencache, DispatchWithEvents, constants 

두 번째 작업으로 여기 로그인에 대한 조치에 포함처럼

는이 모든 설치가 필요합니다 pywin32를 시작하려면 OTAapi가

파일 DLL을 포함하는 모든 방법의 서버

def connect_server(qc, server): 
     '''Connect to QC server 
     input = str(http adress) 
     output = bool(connected) TRUE/FALSE ''' 
     try: 
      qc.InitConnectionEx(server); 
     except: 
      text = "Unable connect to Quality Center database: '%s'"%(server); 
     return qc.Connected; 

def connect_login(qc, username, password): 
    '''Login to QC server 
    input = str(UserName), str(Password) 
    output = bool(Logged) TRUE/FALSE ''' 
    try: 
     qc.Login(username, password); 
    except pywintypes.com_error, err: 
     text = unicode(err[2][2]); 
    return qc.LoggedIn; 

def connect_project(qc, domainname, projectname): 
    '''Connect to Project in QC server 
    input = str(DomainName), str(ProjectName) 
    output = bool(ProjectConnected) TRUE/FALSE ''' 

    try: 
     qc.Connect(domainname, projectname) 
    except pywintypes.com_error, err: 
     text = "Repository of project '%s' in domain '%s' doesn't exist or is not accessible. Please contact your Site Administrator"%(projectname, domainname); 
    return qc.ProjectConnected; 

두 번째 6,

def qc_instance(): 
     '''Create QualityServer instance under variable qc 
     input = None 
     output = bool(True/False)''' 
     qc= None; 
     try: 
      qc = w32c.Dispatch("TDApiole80.TDConnection"); 
      text = "DLL QualityCenter file correctly Dispatched" 
      return True, qc; 
     except: 
      return False, qc; 

이어서 메인있어서

def qcConnect(server, username, password, domainname, projectname): 
    print("Getting QC running files"); 

    status, qc = qc_instance(); 
    if status: 
     print("Connecting to QC server"); 
     if connect_server(qc, server): 
      ##connected to server 
      print("Checking username and password"); 
      if connect_login(qc, username, password): 
       print("Connecting to QC domain and project"); 
       if connect_project(qc, domainname, projectname): 
        text = "Connected" 
        connected = True; 
        return connected, text; 
       else: 
        text = "Not connected to Project in QC server.\nPlease, correct DomainName and/or ProjectName"; 
        connected = False; 
        return connected, text; 
      else: 
       text = "Not logged to QC server.\nPlease, correct UserName and/or Password"; 
       connected = False; 
       return connected, text; 
     else: 
      text = "Not connected to QC server.\nPlease, correct server http address"; 
      connected = False; 
      return connected, text; 
    else: 
     connected = False; 
     text = "Unable to find QualityCenter installation files.\nPlease connect first to QualityCenter by web page to install needed files" 
     return connected, text; 

을 QCserver에 연결하고, 마지막에 어떻게 임의의 경우에 사용

if __name__ == "__main__": 
    server= r"http://qualitycenterServer:8080/qcbin" 
    username= "alex_qc" 
    password= "" 
    domainname= "DEFAULT" 
    projectname= "QualityCenter_Demo" 

    connection_status, text = qcConnect(server, username, password, domainname, projectname); 
    print "connection_status:", connection_status 

예로 한 장소에서 이러한 모든 방법을 실행하도록 more question mailto : [email protected] 또는 웹 페이지로 바로 연결 : http://www.qcintegration.com

1

Windows COM 구성 요소를 실행하지 않고 Linux에서 액세스하려면 REST API to HPQC (ALM11 이상)이 있습니다.

다음은 인증 후 "요구 사항"레코드 (# 1202)를 가져 오는 예제입니다.

import requests 
session = requests.session() 
user='hpqc' 
password='xxxxx' 
r = session.get("http://hpqc-server:8080/qcbin/authentication-point/authenticate",auth=(user,password)) 

r = session.get("http://hpqc-server:8080/qcbin/rest/domains/Foo/projects/Bar/requirements/1202") 
print(r.text) 

XML에서 r.text의 구문 분석은 연습으로 남겨 둡니다.

1

파이썬 또는 Java 기반 솔루션을 요청했지만 insde HPQC/ALM의 스크립트 편집기 (결함 모듈 스크립트)를 사용하여 목표를 달성 할 수있는 다음 VBA 코드를 공유하십시오.

Function Bug_FieldCanChange(FieldName, NewValue) 

On Error Resume Next 

if not changed then 
strCommentBeforeUpdate = Bug_Fields("BG_DEV_COMMENTS").Value 
end if 

If FieldName = "BG_DEV_COMMENTS" and blnAddCommentClicked = False Then 
    Msgbox "Cannot update the comments." & Chr(13)& "Changes made will not be saved."&Chr(13)& "Please use 'Add comment' button to insert new comment." &Chr(13)& " Or click Cancel without saving." 
    blnUpdateCommentError = true 
    blnAddCommentClicked = False 
    changed = true 
    End If 
Bug_FieldCanChange = DefaultRes 

End Function 
관련 문제