Поля поиска в HP Quality Center - PullRequest
       21

Поля поиска в HP Quality Center

3 голосов
/ 14 декабря 2011

Я взаимодействую с Центром качества через API Open Test Architecture.

Я бы хотел определить допустимые значения полей ошибок, связанных с таблицей поиска.

Они доступны через выпадающие списки в стандартном интерфейсе.

Спасибо

Редактировать: более подробное объяснение

У нас есть несколько полей, которые позволят помещать в них только определенные значения.

Например: Действие NextAction может быть одним из следующих {"1. Определить", "2. Анализ", "3. Проектирование"}

Но мне не удалось найти способ программно определить эти допустимые значения.

Ответы [ 2 ]

2 голосов
/ 12 января 2012

Используя объект BugFactory, вы можете получить доступ к полям и их атрибутам.Это прямое копирование / вставка Visual Basic из справочного файла OTA API Reference.Если вам нужна дополнительная помощь, попробуйте задать более сфокусированный вопрос, например, что вы пытаетесь достичь, с какими полями и на каком языке вы пытаетесь получить доступ.

Public Sub CheckValidValue(Optional TableName As String = "BUG")
    Dim BugFact As BugFactory 
    Dim BugList As list 
    Dim aField As TDField 
    Dim fieldList As list 
    Dim rc, ErrCode As Long 
    Dim aBug As Bug 
    Dim msg$ 
    Dim okCnt%, noNodeCnt%, errorCnt%, unknownCnt% 
    Dim dataType As Long 

'------------------------------------------------ 
' User BugFactory.Fields to get a list of TDField 
' objects in the bug table. 
' This example uses the BugFactory, but this can 
' be done with any class that implements IBaseFactory 
    'tdc is the global TDConnection object. 
    Set BugFact = tdc.BugFactory 
    Set fieldList = BugFact.Fields 

'------------------------------------------ 
' Use List.Count to check how many items. 
    Debug.Print: Debug.Print 
    Debug.Print "There are " & fieldList.Count & _
        " fields in this table." 
    Debug.Print "----------------------------------" 
'Get any bug. To look at field attributes we 
' need a valid object and since this example is 
' not interested in the particular values of the object, 
' it doesn't matter which bug. 
    Set BugList = BugFact.NewList("") 
    Set aBug = BugList(0) 

'Walk through the list 
    For Each aField In fieldList 

        With aField 
        'Quit when we have enough for this example 
        If InStr(aField.Name, "BG_USER_10") > 0 Then Exit For 

        ' For the DataTypeString() code, 
        ' see example "Convert data types to string" 
        Debug.Print .Name & ", " & .Property & ", Data type is " _
            & DataTypeString(.Type) 
        On Error Resume Next 
'---------------------------------------------------- 
'Use TDField.IsValidValue to confirm that a value can 
'be used for a field. 
' Get the correct data type and check validity of an 
' arbitrary value. 
' Save the error code immediately after IsValidValue call 
' before another call can change the err object. 
        dataType = aField.Type 
        Select Case dataType 
            Case TDOLE_LONG, TDOLE_ULONG 
                aField.IsValidValue 5, aBug 
                ErrCode = err.Number 
            Case TDOLE_FLOAT 
                aField.IsValidValue 5.5, aBug 
                ErrCode = err.Number 
            Case TDOLE_STRING 
                aField.IsValidValue "Joe", aBug 
                ErrCode = err.Number 
            Case Else 
            'These will be errors: 
                aField.IsValidValue _
                    "String to non-string value", aBug 
                ErrCode = err.Number 

        End Select 

'Output an error code message 
        If ErrCode = 0 Then 'S_OK 
            msg = "Valid Value" 
            okCnt = okCnt + 1 
        Else 
             rc = ErrCode - vbObjectError 
             Select Case rc 
                Case FIELD_E_VERIFIED 
                    msg = "Error: Invalid value for field" 
                    errorCnt = errorCnt + 1 
                Case TDOLE_NONODE 
                    msg = "Error: Field can not be set to this value" 
                    noNodeCnt = noNodeCnt + 1 
                Case Else 
                    msg = "Unrecognized error: " & rc _
                        & " , HRESULT = " & ErrCode 
                    unknownCnt = unknownCnt + 1 
            End Select 
        End If 
        Debug.Print vbTab & msg 
        ' 
        End With 'aField 
    Next aField 

    Debug.Print "----------------------------------" 
    Debug.Print "Number of fields with valid value = " & okCnt 
    Debug.Print "Number of fields with invalid type = " & errorCnt 
    Debug.Print "Number of fields with invalid value= " & noNodeCnt 
    Debug.Print "Number of fields with unknown error = " & unknownCnt 
    Debug.Print "----------------------------------" 
End Sub 
1 голос
/ 08 ноября 2012

Вы можете сделать это, посмотрев на список из объекта «Настройки». Вот как я это сделаю, используя ruby:

qc = WIN32OLE.new('TDApiOle80.TDConnection')        
qcserver = 'http://testdirector/qcbin/'
qc.InitConnectionEx(qcserver)                      
qc.Login($username, $password)                       
qc.Connect("$domain", "$project")                  
customization = @qc.Customization
list = custom.Lists.List("NextAction")
node = list.RootNode
children = node.Children
children.each do |child| 
  puts "#{child.Name} \n"
end
...