如何使用OTA API在ALM中使用交叉过滤器过滤/获取测试实验室实例/配置?

时间:2016-01-19 18:45:26

标签: api customization alm ota qc

您好我正在尝试使用从ALM GUI获得的复杂过滤器获取测试配置列表(来自按钮复制过滤器设置)

[Filter]{
TableName:CYCLE,
ColumnName:CY_CYCLE_ID,
LogicalFilter:409,
VisualFilter:409,
NO_CASE:
}
{
TableName:CYCLE,
ColumnName:CY_FOLDER_ID,
LogicalFilter:\0000001a\^Root\Test sety 01\Podzim^,
VisualFilter:\0000001a\^Root\Test sety 01\Podzim^,
NO_CASE:
}
{
FLT:[X],
TYPE:TESTSET-TSTEST,
EXISTS_IN_IDS:Y,
IN_IDS:\0000007a\[Filter]{
TableName:TESTCYCL,
ColumnName:TC_TESTER_NAME,
LogicalFilter:username,
VisualFilter:username,
NO_CASE:
}

}

我只知道如何使用

轻松过滤
TestConfigFactory.Filter.SetXFilter ("Value from database") = "Value"

我只在OTA API文档中找到了这个例子:

' Get the Test filter object. This filter is unconditional.
' We want all the tests from the test set.
'
    Dim testF As TestFactory, testFilter As TDFilter
    Set testF = tdc.TestFactory
    Set testFilter = testF.Filter

' Set the cross filter: All tests associated with the
' test sets that meet the criteria - in this case, the
' one test set whose name was passed to this routine.
    testFilter.SetXFilter "TEST-TESTSET", True, tsFilter.Text

ALM Customization中有没有办法像这样实现它?:

   set testConfigFact = TDConnection.TestConfigFactory
   set testConfigFilter = testConfigFact.Filter
   testConfigFilter.SetXFilter ("SOMETHING") = [Filter]{
                TableName:CYCLE,
                ColumnName:CY_CYCLE,
                LogicalFilter:igor,
                VisualFilter:igor,
                NO_CASE:
                }
   set testConfigList = testConfigFilter.NewList()
   set testCfg = testConfigList.Item(1)
   msgbox "test config: " & testCfg.ID

2 个答案:

答案 0 :(得分:0)

据我所知,无法使用交叉过滤器从任何其他实体获取TestConfig实体。

试试这个(在C#中):

TSTestFactory tsTestFact = entTestSet.TSTestFactory;

// tdFilter is the TDFilter you want to apply to __TestInstances__
List tsTestList = tdFilter == null ?  
    tsTestFact.NewList(String.Empty) :
    tsTestFact.NewList(tdFilter.Text);

foreach (TSTest testInstance in tsTestList)
{
    TestConfig testConfig = testInstance.TestConfiguration;
}

希望这有帮助。

答案 1 :(得分:0)

实际上您可以使用F#直接使用复制的过滤器文本(对于C#,它非常相似,只需使用复制的过滤器设置filter.Text):

let bf = connection.BugFactory :?> BugFactory
let filter = bf.Filter :?> TDFilter
filter.Text <- @"[Filter]{
TableName:BUG,
ColumnName:\00000012\BG_DETECTED_IN_REL,
SortOrder:2,
SortDirection:0,
NO_CASE:
}
{
TableName:BUG,
ColumnName:BG_RESPONSIBLE,
LogicalFilter:[CurrentUser],
VisualFilter:[CurrentUser],
NO_CASE:
}
{
TableName:BUG,
ColumnName:BG_SUMMARY,
SortOrder:1,
SortDirection:0,
NO_CASE:
}
[Grouping]{
ColumnName:BG_STATUS,
GroupOrder:1
}"
let result = bf.NewList(filter.Text)
printfn "%d" result.Count

但是如果你想修改你复制的过滤文本,那将不是很方便。例如,在代码块行5中,在\ 00000012 \ BG_DETECTED_IN_REL中,\ 000000X \在HEX中定义了它的后缀值“BG_DETECTED_IN_REL”的长度,其具有18个字符。因此,如果您修改了任何具有******** \前缀的值,则还应相应地修改前缀。

但是,我认为使用XFilter更简单方便。