How to programatically add a run to quality center using the ota api through excel vba
Question ID: 105493

How can we programatically add a run to quality center 11.52 using the ota api through excel vba?

Marked as spam
Posted by (Questions: 100, Answers: 4)
Asked on July 11, 2014 8:12 pm
Answers (2)
Private answer

First you will need to find the proper test instance entity from the test set factory, then you will create a new run and post it to that test instance. See the example code below that I wrote awhile back, make sure and use qcRunFactory.AddItem(RunName) or something with a variable in it, if you use qcRunFactory.AddItem(NULL) as in the HP ota api guide the run is created as a ''Draft Run'' and the status doesn't appear in the test grid.....

This code is for demonstration purposes and very basic and I have the test item #'s hard coded in, you will need to edit and create loops to cycle through to find the proper tests that you want to modify....

Dim tdc

Dim TSetFact
Dim theTestSet
Dim testsettreemanager
Dim tsFolder
Dim tsList
Dim tstreemgr
Dim thetest
Dim findtest
Dim found_test_instances
Dim TSTestFactory
Dim testsetslist
Dim qcRunFactory
Dim qcRun
Dim newrun

Set tdc = CreateObject(''TDApiOle80.TDConnection'')
tdc.InitConnectionEx ''http://winserv2012:8080/qcbin''
tdc.Login ''qcadmin'', ''qcadmin''
tdc.Connect ''DEFAULT'', ''test''

' Get the test set tree manager from the test set factory.
'tdc is the global TDConnection object.
Set TSetFact = tdc.testsetfactory
Set tstreemgr = tdc.testsettreemanager
' Use tstreemgr.NodeByPath
' to get the test set folder.
Set tsFolder = tstreemgr.NodeByPath(''Roottest'')

' Use tsfolder.FindTestSets
' to search for a particular test set.
Set testsetslist = tsFolder.FindTestSets(''ests'')

Set theTestSet = testsetslist.Item(1)

' Get the test set attributes.
With theTestSet
Debug.Print ''Test Set ID = '' & .ID & '', Name = '' _
& .Name & '', TestSetFolder = '' & .TestSetFolder

End With

Set findtest = theTestSet.TSTestFactory
Set found_test_instances = findtest.NewList('''')
Set test_instance = found_test_instances.Item(3)

With test_instance
Debug.Print ''TSTest Name: '' & .Name, ''ID: '' & .ID, _
''TestID: '' & .testID, ''Instance: '' & .instance
End With

Set qcRunFactory = test_instance.RunFactory

Dim RunName As String
RunName = ''Excel Test Run:'' & Date
Set newrun = qcRunFactory.AddItem(RunName)
newrun.Name = ''Test Run From Excel'' & Date
newrun.Status = ''Failed''

Marked as spam
Posted by (Questions: 0, Answers: 364)
Answered on July 11, 2014 8:17 pm
cool, thanks, just got this working
( at August 1, 2014 7:13 pm)
Private answer

Set test_instance = found_test_instances.Item(3)

The code will fail at the above line, if the testset is empty

Marked as spam
Posted by (Questions: 0, Answers: 1)
Answered on September 30, 2015 6:26 pm

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top