The code below is a simple way to show all of the Folders and Tests in the Quality Center test plan. You could use this as a basis to develop a treeview of the testplan in another tool.
This code is designed to be run from Excel VBA, but you can easily adapt it for VBScript. It assumes that you have already connected to Quality Center which is represented by the "tdc" variable in the code.
This should help anyone having problems with the error "Field < Subject > requires a value from the corresponding list" - the answer to this problem is to encapsulate the subject with quotes - shown below with chr(34) wrapped around TS_Subject. It took me 2 hours to resolve that issue, no thanks to the OTA documentation!!
Sub ExploreTestPlan()
Dim TreeMgr As TreeManager
Dim SubjRoot As SubjectNode
Dim TestFact As TestFactory
Dim TestFilter As TDFilter
Dim TestList As List
Dim oTest As Test
Dim SubjectNodeList As List
Dim oSubjectNode As SubjectNode
'*** make sure you have connected to QC with the tdc object ***
Set TreeMgr = tdc.TreeManager
Set SubjRoot = TreeMgr.TreeRoot("Subject")
Set TestFact = tdc.TestFactory
Set SubjectNodeList = SubjRoot.FindChildren("", False, "")
For Each oSubjectNode In SubjectNodeList
'Print out the subject path
Debug.Print oSubjectNode.Path
'Does this have any tests?
Set TestFilter = TestFact.Filter
TestFilter.Filter("TS_SUBJECT") = Chr(34) & oSubjectNode.Path & Chr(34)
Set TestList = TestFact.NewList(TestFilter.Text)
For Each oTest In TestList
Debug.Print "Test Name='" & oTest.Name & "' Test Type=" & oTest.Type
Next
Next
End Sub
5 comments:
I was stuck with this error "Field < Subject > requires a value from the corresponding list" until I found your blog. Thanks a lot!
Thanks, David!
Works like a charm.
Hi,
Any idea about the equivalent statement for this filter in C#
TestFilter.Filter("TS_SUBJECT") = Chr(34) & oSubjectNode.Path & Chr(34)
first I tried, TestFilter.Filter["TS_SUBJECT"] = aSomeNode.path;
I got the error in the ield < Subject > requires a value from the corresponding list" in first time.
when I tried this TestFilter.Filter["TS_SUBJECT"] = @"""" + aSomeNode.path + @"""";
it look some thing better, but the same error came after some iterations.
Kettic UI Test control
Post a Comment