QC OTA - Test Lab
- Create Test Set
- Add tests to Test Set
- Create the supplied directory structure in the test lab
- Create a test set underneath a given parent
- Return a test set if it exists
- Returns a testsetfolder for the given path
Public Function TestLabCreateTestSet(strFolderPath As String, strTestSetName As String, ByRef CreatedTestSet As TestSet)
Dim tstSetFolder As TestSetFolder
Dim testSetFolderF As TestSetTreeManager
Dim TestSetF As TestSetFactory
Dim testSet1 As TestSet
Dim oTestSet As TestSet
'Does the test set already exist? If so return it
Set oTestSet = TestLabGetTestSet(strFolderPath, strTestSetName)
If Not (oTestSet Is Nothing) Then
'MsgBox "Test Set Already Exists: " & strFolderPath & "\" & strTestSetName
Set CreatedTestSet = oTestSet
Exit Function
End If
Set testSetFolderF = tdc.TestSetTreeManager
Set tstSetFolder = TestLabGetFolderByPath(strFolderPath)
Set TestSetF = tstSetFolder.TestSetFactory
Set testSet1 = TestSetF.AddItem(Null)
testSet1.Name = strTestSetName
testSet1.Status = "Open"
testSet1.Field("CY_USER_01") = "Reviewed"
'testSet1.
testSet1.Post
If Err = 0 Then
TestLabCreateTestSet = True
Set CreatedTestSet = testSet1
Else
MsgBox Err.Description TestLabCreateTestSet = False
End If
End Function
----------------------------------------------------------Dim testSetFolderF As TestSetTreeManager
Dim TestSetF As TestSetFactory
Dim testSet1 As TestSet
Dim oTestSet As TestSet
'Does the test set already exist? If so return it
Set oTestSet = TestLabGetTestSet(strFolderPath, strTestSetName)
If Not (oTestSet Is Nothing) Then
'MsgBox "Test Set Already Exists: " & strFolderPath & "\" & strTestSetName
Set CreatedTestSet = oTestSet
Exit Function
End If
Set testSetFolderF = tdc.TestSetTreeManager
Set tstSetFolder = TestLabGetFolderByPath(strFolderPath)
Set TestSetF = tstSetFolder.TestSetFactory
Set testSet1 = TestSetF.AddItem(Null)
testSet1.Name = strTestSetName
testSet1.Status = "Open"
testSet1.Field("CY_USER_01") = "Reviewed"
'testSet1.
testSet1.Post
If Err = 0 Then
TestLabCreateTestSet = True
Set CreatedTestSet = testSet1
Else
MsgBox Err.Description TestLabCreateTestSet = False
End If
End Function
Public Function TestLabAddTestToTestSet(ByVal objTestSet As TestSet, ByVal objTest As Test, ByRef objTestInTestSetObj) As Boolean
Dim testInstanceF As TSTestFactory
On Error GoTo ErrTrap
'Get or create a test instance from the factory of the new test set
Set testInstanceF = objTestSet.TSTestFactory
Set objTestInTestSetObj = testInstanceF.AddItem(objTest.ID)
objTestInTestSetObj.Status = "No Run"
objTestInTestSetObj.Post
TestLabAddTestToTestSet = True
Exit Function
ErrTrap:
MsgBox Err.Description, vbCritical, "TestLabAddTestToTestSet"
TestLabAddTestToTestSet = False
End Function
------------------------------------------------------------------------
Public Sub TestLabCreateDirectoryStructure(ByVal strPath As String)
Dim arrPath
Dim n As Integer
Dim strCurrentPath
Dim strLastParent
Dim strLeft
'If they have supplied "root\" in the start of the string, strip this out
If Len(strPath) > 5 Then
strLeft = Left(strPath, 5)
If UCase(strLeft) = "ROOT\" Then
strPath = Right(strPath, Len(strPath) - 5)
End If
End If
arrPath = Split(strPath, "\")
strCurrentPath = "Root"
strLastParent = "Root"
'Create the directory
For n = 0 To UBound(arrPath)
'Update the current path value
strCurrentPath = strCurrentPath & "\" & arrPath(n)
'If the folder does not exist, create it
If Not TestLabDoesFolderExist(strCurrentPath) Then
Call TestLabCreateTestSetFolder(strLastParent, arrPath(n))
End If
'Update last parent
strLastParent = strLastParent & "\" & arrPath(n)
Next n
End Sub
----------------------------------------------------------------------
Public Function TestLabCreateTestSetFolder(ByVal strParentPath As String, ByVal strFolderName As String)
If strFolderName = "" Then
TestLabCreateTestSetFolder = False
Exit Function
End If
'Add test set folder.
Dim TestSetF As TestSetTreeManager
Dim objParent As TestSetFolder
Dim folder As TestSetFolder
Set TestSetF = tdc.TestSetTreeManager
Set objParent = TestLabGetFolderByPath(strParentPath)
Set folder = objParent.AddNode(strFolderName)
folder.Post
If Err = 0 Then
TestLabCreateTestSetFolder = True
Else
MsgBox Err.Description
TestLabCreateTestSetFolder = False
End If
End Function
-----------------------------------------------------------------------
Public Function TestLabDoesFolderExist(ByVal strPath As String)
On Error Resume Next
Dim tstSetFolder As TestSetFolder
Dim testSetFolderF As TestSetTreeManager
Dim objCurrentFolder As TestSetFolder
Dim lastFolder As TestSetFolder
Dim n
Dim arrPath
Set testSetFolderF = tdc.TestSetTreeManager
Set lastFolder = testSetFolderF.Root
'For some reason, NodeByPath is not working, but we can check it by getting the children
arrPath = Split(strPath, "\")
If UBound(arrPath) > 0 Then
For n = 1 To UBound(arrPath)
Set objCurrentFolder = Nothing
Set objCurrentFolder = lastFolder.FindChildNode(arrPath(n))
Set lastFolder = objCurrentFolder
Next n
End If
If (objCurrentFolder Is Nothing) Then
TestLabDoesFolderExist = False
Else
TestLabDoesFolderExist = True
End If
On Error GoTo 0
End Function
-------------------------------------------------------------
Public Function TestLabGetFolderByPath(strPath As String) As TestSetFolder
Dim objTestTreeManager As TestSetTreeManager
Dim objCurrentFolder As TestSetFolder
Dim arrPath
Dim n
'Get the tree manager
Set objTestTreeManager = tdc.TestSetTreeManager
'Get the root object - we will search the children of this
Set objCurrentFolder = objTestTreeManager.Root
'Split out the path
arrPath = Split(strPath, "\")
'We already have the root as an object so skip element 0
If UBound(arrPath) > 0 Then
'Loop through the path, getting each folder as a child
For n = 1 To UBound(arrPath)
Set objCurrentFolder = objCurrentFolder.FindChildNode(arrPath(n))
Next n
End If
Set TestLabGetFolderByPath = objCurrentFolder
End Function
--------------------------------------------------------------------
Public Function TestLabGetTestSet(ByVal strFolderPath As String, ByVal strTestSetName As String) As TestSet
Dim tsFilter As TDFilter
Dim tsList As IList
Dim oTestSetFolder As TestSetFolder
Dim aTestSet As TestSet
Dim TSetFact As TestSetFactory
Dim arrFolderPath() As String
'Get the folder
Set oTestSetFolder = TestLabGetFolderByPath(strFolderPath)
Set TSetFact = tdc.TestSetFactory
'When looking for the test sets we can use the "CY_FOLDER_ID" property. This contains the name of the parent folder
'So we just need to extract what the name of the parent folder is
arrFolderPath = Split(strFolderPath, "\") 'break up the paths so the parent folder is in the upper bound
'Create the filter:
Set tsFilter = TSetFact.Filter
'Get a list of the test sets - this will contain all of the child test cases
Set tsList = oTestSetFolder.FindTestSets("", False, tsFilter.Text)
If Not (tsList Is Nothing) Then
For Each aTestSet In tsList
'Does this test set name and path match what we are looking for?
If (UCase(aTestSet.TestSetFolder.Path) = UCase(strFolderPath)) And (UCase(aTestSet.Name) = UCase(strTestSetName)) Then
'Return value & cleanup
Set TestLabGetTestSet = aTestSet
Set tsList = Nothing
Set tsFilter = Nothing
Set TSetFact = Nothing
Set oTestSetFolder = Nothing
Exit Function
End If
Next aTestSet
End If
'no matches found, return nothing
Set TestLabGetTestSet = Nothing
Set tsList = Nothing
Set tsFilter = Nothing
Set TSetFact = Nothing
Set oTestSetFolder = Nothing
End Function
Source: http://automationandtesting.blogspot.co.uk/2011/11/treeview-for-quality-center-test-plan.html
Hi Aditya,
ReplyDeleteI would like get the count of test sets in subfolders.
EX: root\test where test is main folder after root. When test has two sub folders named test1 and test2 and each having 5 test sets , how can I get the count of test sets in these sub folders.
Thanks
Praveen
This should do what you are looking for:
ReplyDeletehttp://stackoverflow.com/questions/4212316/quality-center-ota-api-return-just-the-first-level-of-child-testsets-in-a-tests
Let me know if you are facing trouble.
This comment has been removed by the author.
ReplyDeleteHi Aditya,
ReplyDeleteVery good post.
I am trying this code, facing issue at 'TestSetTreeManager'.
My code is:
Set tdc= CreateObject("TDApiOle80.TDConnection")
------------Aithenticating Successfully...
------logged into the project--------------
//Now I am trying to get TestSetTreeManager
Set objTestTreeManager = tdc.TestSetTreeManager //Here I am getting error "User Defined Type not defined".
Can you please let me know if i need to do anything else in my script.
I am very new to VB Script. Your help in resolving this issue is appreciated.
Thanks,
Lenina
Hi Lenina,
DeleteThe "TestSetTreeManager" is a child method of the TDConnection object. The code that is presented here is in vba and not vbscript therefore you would notice a line that says "Dim objTestTreeManager As TestSetTreeManager"
If you want to do the same in vbscript then you need to create it under a particular folder under the testlab tree :
Set objTestTreeManager = tdc.TestSetTreeManager.NodeByPath("Root\TBD\TEST")
Best Regards,
Ady
"Besides black art, there is only automation"
Technology Specific Guide For QTP - My new Book on QTP
Hi Adiya,
ReplyDeleteI was trying to pull the reports from QC for the test cases executed based on the TestSet folder. For example:
I have following root folder for the test lab
root\application1\release 1\SIT
Within that i have multiple folders
\folder1 (may have sub folders)
\folder 2 (may have sub fodlers)
And each end level folders may have multiple test sets.
I was wondering if you have a code which takes the test lab root folder say in my case "root\application1\release 1\SIT" from the test lab and gives me the test name and status for each of the test cases across the test sets and test set folders within the root folder.
Appreciate your help.
-Mahavir
Hi, can any one explain how to attach any excel report to qc using OTA util ?
ReplyDeleteVini - This might help http://go-gaga-over-testing.blogspot.in/2012/10/important-reusable-functions-qtp.html , let me know if you find any success..
ReplyDeleteBest Regards,
Ady
Hi aditya ,
ReplyDeleteThis satish from Chennai , i have a query regarding Automation QC , my requirement to pull all the property of the testcase from QC using vbscript (Need all testfield)
Hi Aditya,
ReplyDeleteI need to create a status report for all test cases in particular folder. Folder path is like Root\Dry Run\System Integration, inside system integration there are multiple folders and each folder contains multiple test sets.
Can you please help how can i generate the report.
Structure is like:
Root\Dry Run\System Integration\Test1 - Test1 contains multiple folders name: Test11, Test12, Test13 and each folder contains multiple test sets
what value i need to pass in the ByRef CreatedTestSet As TestSet in the first function while creating the testset.
ReplyDeletehow to set the test set details tab fields using OTA? like designer status and all
ReplyDeleteHi Aditya,
ReplyDeleteGreat article exactly what i was looking,
What I am trying to do is to create test lab using your function "TestLabAddTestToTestSet"
Can you please tell me what i need to pass in objTest.ID?? Is it the test id of the test case in test plan tree?
I did this and I am getting error test not found.
Thanks
yatharth
I have baselined some tests in ALM 11.00.
ReplyDeleteCreated a "Pinned to Baseline" test set.
Trying to run those baselined tests, via QTP, from the "pinned to baseline" test set.
At runtime I want to check if a test is “pinned to baseline” from QC (will be using Test.VCS properties for this) but not sure how to use that to grab it’s resources (parameters,attachments etc) of the same baseline?
The DownloadResource functionality only appears to get the latest and not a specified version.
Any help would be appreciated.
Thanks,
Shaun
Hi Aditya, I found your blog whilst looking for something else. This is code I posted a while ago, I'm happy that it's being used but it would be nice if you put a reference to my blog where it was originally from.
ReplyDeletehttp://automationandtesting.blogspot.co.uk/
Regards
David Hartley
Hi David,
DeleteI am extremely sorry I generally post a reference if I pick anything from any blog(with permission). This was shared by a friend I shall go ahead and add a reference to your blog. Please let me know if you want me to remove this post and I wouldn't mind that.
Best Regards,
Ady
No problem Ady, please keep this page active as it will help everyone else and just reference my blog. This is the original page: http://automationandtesting.blogspot.co.uk/2011/11/treeview-for-quality-center-test-plan.html
DeleteHappy for you to delete this thread from the page.
Best wishes
Dave
Thanks David,
DeleteMore than happy to let this thread stay so people can redirect while they read comments.
I will anyway add a reference to your page.
Cheers,
Ady
Hi
ReplyDeleteHow do I get test runs from the run table?
Please help
You would want to have a look at this http://automationandtesting.blogspot.co.uk/2011/11/treeview-for-quality-center-test-plan.html
Deletethanks for this informative blog posting.. keep posting, keep updating and keep blogging..
ReplyDeletepathology lab in janakpuri
In 2003 I was using the ALM AOM when it was TD and QC. I have not looked at it since then. I'm trying to find out how to append some text into the pass/fail area of a test run. It says Description, expected, actual. After the run is complete I wish to add some more information to this field in the Test Lab. I can use some assistance.
ReplyDeletecurry 7 sour patch
ReplyDeletemoncler outlet
golden goose sneakers
birkin bag
pandora
lebron 18
jordan shoes
stephen curry shoes
golden goose
jordan shoes
I need to fetch the the parameters values are which are present in execution settings for each iteration in test lab using OTA. Can anyone please help
ReplyDelete