

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I want to retrieve the TS_TEST_ID but i am not getting the testname TestFact.AddItem(TestName).
Please help. I am using QTP 10, alm 11.00 patch 7.
Public Function fAddTest(TestName, Testid)
Dim objTdConnection
Dim objTestFactory
Dim objTestList
Dim objTest
Dim strTestFactoryFilter
Dim MyTest
Set QCConnection = QCUtil.TDConnection
'VerIfy If the test in the test plan otherwise it creates the test in the test plan as QTP type test
Set TestFact = QCConnection.TestFactory
Set MyTMgr = QCConnection.TreeManager
Set MySRoot =MyTMgr.NodeByPath(Environment.Value("TEST_PLAN_PATH"))
strTestFactoryFilter = "select TS_TEST_ID from TEST where TS_NAME = '" & TestName & "' and TS_SUBJECT = " & MySRoot.NodeID
Err.Clear
On Error Resume Next
Set objTestList = TestFact.NewList(strTestFactoryFilter)
If Err.Number > 0 or objTestList.Count = 0 Then
Set MyTest = TestFact.AddItem(TestName)
MyTest.Field("TS_SUBJECT")= MySRoot.NodeID
MyTest.Field("TS_TYPE") ="QUICKTEST_TEST"
MyTest.Post
Testid = MyTest.id
fAddTest = True
Exit Function
End If
If objTestList.Count > 0 Then
TestFound = True
Set objTest = objTestList.Item(1)
Testid = objTest.id
Set TestSetF = MyTest.TSTestFactory
Set MyTest = TestSetF.addItem(Testid)
MyTest.Status =Status
MyTest.Post
End If
fAddTest = True
End Function
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I suggest you try this instead
If Err.Number > 0 or objTestList.Count = 0 Then Set MyTest = TestFact.AddItem(Null) MyTest.Name = TestName MyTest.Field("TS_SUBJECT")= MySRoot.NodeID MyTest.Type ="QUICKTEST_TEST" MyTest.Post Testid = MyTest.id fAddTest = True Exit Function End If
(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
I suggest you try this instead
If Err.Number > 0 or objTestList.Count = 0 Then Set MyTest = TestFact.AddItem(Null) MyTest.Name = TestName MyTest.Field("TS_SUBJECT")= MySRoot.NodeID MyTest.Type ="QUICKTEST_TEST" MyTest.Post Testid = MyTest.id fAddTest = True Exit Function End If
(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Thanks a lot. It worked.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
I have followed the similar steps mentioned.
I am trying to run the SQL to fetch the count on TS_STATUS for some specific dates using NODEID (TS_SUBJECT) from TestPlan (Test table) to populate in MS Excel2007 using macros. When I run the query "Failed to Get Test value" is the error description I am getting even when I change the query as "Select count(*) from Test" is also failing with same error. Trying checking QC connection but returns true for connection.
My script as below, request to please do the needful at the earliest.
Set TestFact = oQCConn.TestFactory
Set oQCTestTree = oQCConn.TreeManager
Set folder = oQCTestTree.NodeByPath(aTestPlanValues(i))
'TS_Status,
strSQLQuery = "SELECT count(*) as count FROM Test where ts_subject =" & folder.NodeID & " and TS_CREATION_DATE " & _
"Between '" & dtStartDate1 & "' and '" & dtEndDate1 & "' group by ts_Status"
Err.Clear
On Error Resume Next
Set tList = TestFact.NewList(strSQLQuery)
MsgBox Err.Description