Quality Center OTA API:仅返回 TestSetFolder 中的第一级子 TestSet

发布于 2024-10-03 06:22:06 字数 1948 浏览 0 评论 0原文

HP QC OTA API 似乎提供了两种方法来返回指定 TestSetFolder 中的 TestSet 列表。然而,这两种方法都是递归的,并返回层次结构中每个子文件夹的所有测试集。我希望能够仅返回任何给定测试集文件夹的直接子测试集。我意识到这可以通过使用 Command 对象的非常简单的 SQL 查询来实现,但由于需要 QC 权限,这在我的场景中不是一个选项。

请考虑下面的 C# 代码示例。 这里使用标准QC示例项目来说明问题。 使用“Root\Mercury Tours Web Site\Functionality And UI”文件夹路径,在所有情况下都正确返回 3 个测试集。但是,指定“Root\Mercury Tours Web Site”的路径会返回 5 个测试集,因为示例包含分别包含 3 个和 2 个测试集的 2 个子文件夹。在这种情况下,SQL 不会正确返回任何测试集。

// where 'tdc' is a valid TDConnection object logged in to DEFAULT.QualityCenter_Demo
// string testSetFolderPath = @"Root\Mercury Tours Web Site";                          // 0 test sets (Method 1 and 2 return 5)
string testSetFolderPath = @"Root\Mercury Tours Web Site\Functionality And UI";     // 3 test sets

// Method 1: TestSetFolder.FindTestSets()
var testSetTreeManager = (TestSetTreeManager)tdc.TestSetTreeManager;
var testSetFolder = (TestSetFolder)testSetTreeManager.get_NodeByPath(testSetFolderPath);
var testSets = testSetFolder.FindTestSets("", false, "");
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

// Method 2: NewList() with filter
var testSetFactory = (TestSetFactory)tdc.TestSetFactory;
var filter = (TDFilter)testSetFactory.Filter;
filter["CY_FOLDER_ID"] = "^" + testSetFolderPath + "^";
testSets = (List)testSetFactory.NewList(filter.Text);
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

// Method 3: SQL Query using Command object
var command = tdc.Command;
command.CommandText = "select CY_CYCLE as TestSet from CYCLE where CY_FOLDER_ID = " + testSetFolder.NodeID;
Recordset records = command.Execute();
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, records.RecordCount);

可以迭代返回的测试集来检查 TestSetFolder 路径属性是否与当前文件夹匹配。然而,这会导致重大的性能开销,特别是对于大型 QC 项目和/或网络连接速度较慢的情况。

QC 中必须有某种方法来执行此操作,因为当您展开测试集树中的节点时,QC Web UI 和 QCExplorer 工具都会逐步加载测试集。

有什么想法吗?谢谢!

The HP QC OTA API appears to provide two methods for returning the list of TestSets within a specified TestSetFolder. However both methods are recursive and return all the tests sets for every single sub-folder further down the hierarchy. I want to be able to return just the immediate child test sets of any given test set folder. I realise this can be achieved using a very simple SQL query using the Command object but this is not an option in my scenario due to the QC permissions required.

Consider the following c# code sample below.
This uses the standard QC sample project to illustrate the problem.
Using the folder path of "Root\Mercury Tours Web Site\Functionality And UI" the 3 test sets are returned correctly in all cases. However specifying the path of "Root\Mercury Tours Web Site" returns 5 test sets as the sample contains 2 sub folders of 3 and 2 test sets respectively. The SQL correctly does not return any test sets in this case.

// where 'tdc' is a valid TDConnection object logged in to DEFAULT.QualityCenter_Demo
// string testSetFolderPath = @"Root\Mercury Tours Web Site";                          // 0 test sets (Method 1 and 2 return 5)
string testSetFolderPath = @"Root\Mercury Tours Web Site\Functionality And UI";     // 3 test sets

// Method 1: TestSetFolder.FindTestSets()
var testSetTreeManager = (TestSetTreeManager)tdc.TestSetTreeManager;
var testSetFolder = (TestSetFolder)testSetTreeManager.get_NodeByPath(testSetFolderPath);
var testSets = testSetFolder.FindTestSets("", false, "");
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

// Method 2: NewList() with filter
var testSetFactory = (TestSetFactory)tdc.TestSetFactory;
var filter = (TDFilter)testSetFactory.Filter;
filter["CY_FOLDER_ID"] = "^" + testSetFolderPath + "^";
testSets = (List)testSetFactory.NewList(filter.Text);
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

// Method 3: SQL Query using Command object
var command = tdc.Command;
command.CommandText = "select CY_CYCLE as TestSet from CYCLE where CY_FOLDER_ID = " + testSetFolder.NodeID;
Recordset records = command.Execute();
Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, records.RecordCount);

It is possible to iterate through the test sets returned to check that the TestSetFolder path property matches the current folder. However, this results in a major performance overhead, especially for large QC projects and/or over a slow network connection.

There must be some way in QC to do this since both QC web UI and QCExplorer tool load test sets progressively as you expand the nodes in the test set tree.

Any ideas? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

智商已欠费 2024-10-10 06:22:06

事实证明,在 CY_FOLDER_ID 上使用插入符号 (^) 实际上是用于强制执行递归搜索。如果这些被删除并替换为双引号,则不会返回子文件夹中的测试集。因此示例中的方法 2 可以修改为:

// Method 2: NewList() with filter
var testSetFactory = (TestSetFactory)tdc.TestSetFactory;
var filter = (TDFilter)testSetFactory.Filter;
filter["CY_FOLDER_ID"] = "\"" + testSetFolderPath + "\"";    
testSets = (List)testSetFactory.NewList(filter.Text);
if (testSets == null)
    Console.WriteLine("Folder {0} does not contain any testsets", testSetFolderPath);
else
    Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

感谢 Christian Grzelka,他在 SQA 论坛

It turns out that the use of the caret (^) symbols on the CY_FOLDER_ID is actually used to enforce a recursive search. If these are removed and replaced with double-quotes then testsets in sub-folders are not returned. So Method 2 in the example can be modified to:

// Method 2: NewList() with filter
var testSetFactory = (TestSetFactory)tdc.TestSetFactory;
var filter = (TDFilter)testSetFactory.Filter;
filter["CY_FOLDER_ID"] = "\"" + testSetFolderPath + "\"";    
testSets = (List)testSetFactory.NewList(filter.Text);
if (testSets == null)
    Console.WriteLine("Folder {0} does not contain any testsets", testSetFolderPath);
else
    Console.WriteLine("Folder {0} contains {1} testsets", testSetFolderPath, testSets.Count);

Thank-you to Christian Grzelka who answered my post on SQAForums.

扎心 2024-10-10 06:22:06
filter["CY_FOLDER_ID"] = "\"" + testSetFolderPath + "\"";

上述代码在 ALM 11 中无效。它将抛出错误“不是整数值”。

您必须在测试集树管理器上使用 get_NodebyPath 方法。

filter["CY_FOLDER_ID"] = "\"" + testSetFolderPath + "\"";

The above code is not valid from ALM 11. It will throw an error "not an integer value".

You will have to use get_NodebyPath method over a Test Set Tree Manager.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文