HP QC OTA API似乎提供了兩種方法來返回指定TestSetFolder中的TestSets列表。但是,這兩種方法都是遞歸的,並且會將每個子文件夾的所有測試集都還原到層次結構中。我希望能夠僅返回任何給定測試集文件夾的直接子測試集。我意識到這可以通過使用Command對象的非常簡單的SQL查詢來實現,但由於需要使用QC權限,所以在我的場景中這不是一個選項。Quality Center OTA API:僅在TestSetFolder中返回第一級子TestSets
請考慮下面的C#代碼示例。 這使用標準QC樣本項目來說明問題。 使用「Root \ Mercury Tours網站\功能和UI」的文件夾路徑,在所有情況下都能正確返回3個測試集。但是,指定「Root \ Mercury Tours網站」的路徑將返回5個測試集,因爲該示例包含兩個分別包含3個和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工具負載測試在您展開測試集樹中的節點時逐步進行。
任何想法?謝謝!
我試過你的解決方案,但收到一個錯誤_'Root \ Sandbox'不是一個有效的整數值._有沒有我在你的解決方案中缺少的東西? – Harrison 2013-11-07 20:26:02