12-02-2010, 12:02 AM
I was able to add test set but not able to add the test in QC. I would really appreciate if some one could help me on this issue. Below is the code I was trying to use. Please let me know if anyone need more inofrmation.
'-----------------------------------------
' Test Lab
'------------------------------------------
Code:
qcServer ="servername"
Set tdc = CreateObject("TDAPIOLE80.TDConnection")
If (tdc Is Nothing) Then
MsgBox "tdc empty"
Else
Msgbox "Connection object created"
End If
tdc.InitConnectionEx qcServer
tdc.Login "testlogin", "testpassword"
tdc.Connect "domain", "project"
Set TreeMgr = tdc.TreeManager
Set testF = tdc.TestFactory
Set labTreeMgr = tdc.TestSetTreeManager
'-----------------------------------------
' Test Lab
'------------------------------------------
Code:
' Get or create a test set folder.
errmsg = "Lab node error"
Dim tsFolder, tsFolderPath
tsFolder ="CWF_Regression"
tsFolderPath = "Root\" & tsFolder
On Error Resume Next
Set labFolder = labTreeMgr.NodeByPath(tsFolderPath)
' On Error GoTo LinkDefectsToEntitiesErr
If labFolder Is Nothing Then
Set labTreeRoot = labTreeMgr.Root
Set labFolder = labTreeRoot.AddNode(tsFolder)
labTreeRoot.Post
msgbox "Folder Created in TestLab"
Else
Set labTreeRoot = labTreeMgr.Root
Set labFolder = labTreeRoot.AddNode(tsFolder)
labTreeRoot.Post
msgbox "unable to create folder in test lab"
End If
' Get or create a test set from the factory of the new folder.
errmsg = "Test set error"
Dim tsName
TestName = "CWF_Regression"
tsName = TestName
Set testSetF = labFolder.TestSetFactory
Set aFilter = testSetF.Filter
aFilter.Filter("CY_CYCLE") = tsName
Set lst = testSetF.NewList(aFilter.Text)
If lst.Count = 0 Then
Set TstSet = testSetF.AddItem(Null)
TstSet.Field("CY_CYCLE") = tsName
TstSet.Post
Else
Set TstSet = lst.Item(1)
End If
' Get or create a test instance from the factory of the new test set.
Set NewTest = GetTest("C-BR1-FR10-TC1", "Subject\CWF_Regression")
msgbox NewTest.ID
Set NewTest = testF.AddItem(Null)
NewTest.Name = "C-BR1-FR10-TC1"
msgbox NewTest.ID
errmsg = "Test instance error"
Set testInstanceF = TstSet.TSTestFactory
Set aFilter = testInstanceF.Filter
aFilter.Filter("TC_TEST_ID") = NewTest.ID '"C-BR6-FR28-TC19"
Set lst = testInstanceF.NewList(aFilter.Text)
If lst.Count = 0 Then
Set tstInstance = testInstanceF.AddItem(Null)
' Put the new test in the test set.
tstInstance.Field("TC_TEST_ID") = NewTest.ID '"C-BR6-FR28-TC19"
Else
Set tstInstance = lst.Item(1)
End If
tstInstance.Status ="FAILED"