2010-04-13 9 views
7

Abbiamo un progetto che utilizza HP Quality Center e uno dei problemi normali che dobbiamo affrontare è che le persone non aggiornano i commenti sul difetto.Automazione di HP Quality Center con Python o Java

Quindi stavo pensando che avremmo potuto trovare un piccolo script o uno strumento che potesse essere usato per lanciare periodicamente un promemoria e costringere l'utente ad aggiornare i commenti.

Mi sono imbattuto nell'API di Open Test Architecture e mi chiedevo se ci sono dei buoni esempi Python o Java per lo stesso che potevo vedere.

Grazie Hari

risposta

5

Non sono sicuro che ci sono dei buoni esempi per Java, perché OTA non può essere consumato da Java direttamente, ha bisogno di un Java a COM bridnge come JIntegra.

Informazioni su Python, è possibile utilizzare le API COM Python. E poi qualsiasi esempio di OTA farà. Hai un sacco di documentazione QC di OTA.

Ma penso che la vera domanda qui sia, perché vorresti farlo in Python o Java. Perché non scrivere ciò di cui hai bisogno direttamente in QC usando la sua funzione Flusso di lavoro. Che ti consentirà di scrivere la tua logica in VBScript e di invocarla all'interno dell'interfaccia utente di QC sulle azioni dell'utente. Ad esempio, è possibile associare l'evento Post di un difetto/bug e verificare se è presente un commento e se non viene richiesto all'utente di inviare direttamente un messaggio.

+0

Grazie, proverò l'opzione VBScript e vedremo come va. – Hari

0

È possibile utilizzare un nuovo test e selezionare il tipo (VPXP_API) che consente l'esecuzione dello script. La cosa buona è che avresti la definizione della funzione pronta per essere trascinata da QC invece di dover fare molto affidamento su doc. Ho eseguito un'implementazione in Python eseguendo alcuni script da QC usando ancora la sua API ma tramite un test QC che è comodo per recuperare direttamente il risultato (Output) ecc. Passando attraverso un comando shell che può quindi chiamare qualsiasi script su qualsiasi server ecc ...

+0

Vorrei maggiori informazioni su come utilizzare VPXP_API (VAPI_XP_TEST presumo?) Ho usato OTAClient con Python & C# ma ottenere i miei test (ad esempio il selenio) da avviare da QC ancora mi sfugge. – fijiaaron

12

Esempio di utilizzo di Python (win32com) per connettersi a HP Quality Center via OTA

HP Quality Center espone un'API COM based chiamato OTA.

documentazione su questo è scaricabile da un server di controllo di qualità (OTA_API_Reference.chm) (Stranamente è molto difficile da trovare online)

La documentazione utilizza VBScript (Il linguaggio interno ufficialmente supportato per QC) e vi bisogno di tradurre mentalmente in Python. Di solito è molto semplice, ma esistono un paio di trucchi.

È necessario installare sulla macchina il codice locale di Quality Center, si trova su Windows PC se è stato possibile accedere a QC tramite l'interfaccia Web.

Sarà inoltre necessario conoscere l'URL del server e il nome utente e la password e il dominio del progetto QC su cui si sta lavorando.

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  

Questa non è una cattiva base per andare avanti, ma creo una classe fittizia per difetti e eseguire qualcosa di simile:

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

allora posso inserire il codice lavoratore in classe difetto e mantenere le cose più ordinato . Una cosa che vuoi fare è mantenere l'accesso al bug qc interno alla classe wrapper python.

+0

Ciao e grazie per la risposta. Questo è un ottimo punto di partenza! Tuttavia mi piacerebbe sapere se c'è qualche tipo di riferimento (documentazione) per questa interfaccia? –

6

Informazioni per gli altri che potrebbero visualizzare questa discussione.

ricominciare tutto questo è necessario installare pywin32, come da qui http://sourceforge.net/projects/pywin32/files/pywin32/Build216/

Prima di tutto sarà necessario importare pywin32

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

Poi, come seconda operazione ho includere qui l'azione su login per Server

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; 

in secondo luogo di tutto il metodo che includerà OTAapi file dLL

012.
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; 

metodo Poi principale per connettersi a QCserver

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; 

E alla fine come eseguire tutti questi metodi in un luogo con esempio di utilizzo

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 

In caso di qualsiasi ulteriori domande mailto: [email protected] o direttamente sul lato web: http://www.qcintegration.com

1

C'è un REST API to HPQC (ALM11 e successivi) se si desidera accedervi da Linux senza eseguire un componente COM di Windows.

Ecco un esempio che inserisce un record "requisito" (# 1202) dopo l'autenticazione.

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) 

L'analisi di r.text da XML viene lasciata come esercizio.

1

Sebbene sia stata richiesta una soluzione basata su Python o Java, condividere il seguente codice VBA che è possibile utilizzare insde l'editor di script di HPQC/ALM (script del modulo Difetti) per raggiungere l'obiettivo.

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