Using OTA API to update Quality Center test sets (2427 Views)
Reply
Occasional Visitor
cathy baker
Posts: 1
Registered: ‎05-05-2011
Message 1 of 2 (2,427 Views)

Using OTA API to update Quality Center test sets

I've written a vb script to load test set data into QC using the the OTA API. The test set has a Description field (CY_COMMENT) defined as Memo. I cannot update this field with carriage return values in the data. I'd like to preserve the carriage returns but have had to remove them to get the vb script to work.



strRoot = "Root\Template Test Sets\Test\"

Dim objFileSystemObject
Dim objfileSystem

Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")
If (objFileSystemObject Is Nothing) Then
MsgBox ("Not able to create fso")
End If

Set objFileSystem = objFileSystemObject.OpenTextFile("C:\Documents and Settings\Desktop\Scenarios.csv")
If (objFileSystem Is Nothing) Then
MsgBox ("Not able to open file")
End If



If Not (objFileSystem Is Nothing) Then

Dim objTestSetTreeManager
Dim objRootFolder
Dim objTestSetFolder
Dim objTestSetFolderFactory
Dim objTestSetFactory
Dim objTestSet
Dim iCount
Dim strText
Dim strTestSetArray
Dim strTestSet




Set objTestSetTreeManager = tdc.TestSetTreeManager

If Not (objTestSetTreeManager is nothing) then
MsgBox ("objTestSetTreeManager created")
Set objRootFolder = objTestSetTreeManager.NodeByPath(strRoot)
If Not (objRootFolder is nothing) then
MsgBox ("objRootFolder found - " & objRootFolder.Name)
Set objTestSetFactory = tdc.TestSetFactory
End If
End If
iCount = 0
Do Until objFileSystem.AtEndOfStream
strText = objFileSystem.ReadLine
MsgBox ("strtext = " & strText)
strTestSetArray = split(strText,"~")

'0 - subfolder
'1 - name
'2 - description
'3 - track
'4 - module
'5 - risk level
'6 - RICEW id

MsgBox ("0 = " & strTestSetArray(0) & chr(13) & _
"1 = " & strTestSetArray(1) & chr(13) & _
"2 = " & strTestSetArray(2) & chr(13) & _
"3 = " & strTestSetArray(3) & chr(13) & _
"4 = " & strTestSetArray(4) & chr(13) & _
"5 = " & strTestSetArray(5) & chr(13) & _
"6 = " & strTestSetArray(6))

strTestSet = strTestSetArray(0) & " - " & strTestSetArray(1)
'MsgBox ("strTestSet = " & strTestSet)
Set objTestSetFactory = tdc.TestSetTreeManager
Set objTestSetFolder = objTestSetFactory.NodeByPath(strRoot)
Set objTestSetFactory = objTestSetFolder.testsetFactory
Set objTestSet = objTestSetFactory.AddItem(Null)

objTestSet.Status = "Open"
objTestSet.Name = strTestSet
'TestSet parent id
objTestSet.TestSetFolder = objRootFolder.NodeId

'Scenario name
objTestSet.Field("CY_USER_08") = strTestSet
'Scenario Track = CY_USER_02
objTestSet.Field("CY_USER_02") = strTestSetArray(3)
'Module = CY_USER_04
objTestSet.Field("CY_USER_04") = strTestSetArray(4)
'Risk Level = CY_USER_01
objTestSet.Field("CY_USER_01") = strTestSetArray(5)

'Description
objTestSet.Field("CY_COMMENT") = strTestSetArray(2)
'RICEW Id = CYCLE.CY_USER_14
objTestSet.Field("CY_USER_14") = strTestSetArray(6)

'Scenario Scheduled Date = CY_USER_09
objTestSet.Field("CY_USER_09") = ""
'Scenario Retest Scheduled Date = CY_USER_10
objTestSet.Field("CY_USER_10") = ""
'Scenario Retest Date = CY_USER_07
objTestSet.Field("CY_USER_07") = ""
'Scenario Execution Date = CY_USER_06
objTestSet.Field("CY_USER_06") = ""

'Scenario Execution Status = CYCLE.CY_USER_03
objTestSet.Field("CY_USER_03") = "No Run"

objTestSet.Post

iCount = iCount + 1
Loop

MsgBox ("End of loop")
Else
MsgBox ("file system object not created " )
End If

Please use plain text.
Frequent Advisor
AscertRobw
Posts: 73
Registered: ‎01-29-2008
Message 2 of 2 (2,427 Views)

Re: Using OTA API to update Quality Center test sets

Cathy

We've put both CR and LF fields into some QC fields with our plugin and it's worked ok - but I don't think we use them in our formatting of the CY_COMMENT field, so I can't say for sure it would work.

One thing we've found is that it's best to only use them where really necessary - the 0x10 and 0x13 chars can get fiddly in SQL statements for db admins who run conversion or other SQL jobs on the DB

And ... there is an alternative for fileds like CY_COMMENT. These fields can take HTML formatting, so you can use strings like
to insert line breaks. You can also use wrappers etc to pretty up the text with bold, underline etc.
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation