我找到了许多有关通过UFT将资源上传到ALM的示例。 但是,ALM中始终已经创建了一个资源。 如何使用UFT创建资源并将资源上传到ALM? 我的问题是我不知道我需要多少资源,因此我必须先创建资源然后再上传。 我不想将文件作为附件上传到运行。
谢谢
答案 0 :(得分:0)
我想我在这里找到了答案:http://www.codetweet.com/other/create-new-resource-almqc-using-ota/
Sub CreateNewResource(resourceFolderId As Integer, fileType As String, fileName As String, fileParentFolderPath As String)
On Error GoTo Errhandler:
'--- Represents a file or folder stored in the Quality Center repository
Dim resource As QCResource
'--- Represents a QC resource folder.
Dim resourceFolder As QCResourceFolder
'--- Services for managing QC resources.
Dim resourceFactory As QCResourceFactory
'--- Services for managing QC resource folders.
Dim resourceFolderFactory As QCResourceFolderFactory
'--- Services to manage resource storage.
Dim testResourceStorage As IResourceStorage
Dim resourceItem
Dim resourceFound As Boolean
' ***TDConn is TDConnection class object.Create this object before using this function.
Set resourceFolderFactory = TDConn.QCResourceFolderFactory
Set resourceFolder = resourceFolderFactory.Item(resourceFolderId)
Set resourceFactory = resourceFolder.QCResourceFactory
Set currResourceList = resourceFactory.NewList("")
For ItemCount = 1 To currResourceList.Count
currItem = currResourceList.Item(ItemCount).Name
If UCase(currItem) = UCase(fileName) Then
Set resourceItem = currResourceList.Item(ItemCount)
resourceFound = True
Exit For
End If
Next
If Not resourceFound Then
'--- Create a resource
Set resourceItem = resourceFactory.AddItem(fileName)
resourceItem.ResourceType = fileType
resourceItem.fileName = fileName
resourceItem.Post
'--- Check if the resources added successfully
Set currResourceList = resourceFactory.NewList("")
For ItemCount = 1 To currResourceList.Count
currItem = currResourceList.Item(ItemCount).Name
If UCase(currItem) = UCase(fileName) Then
resourceFound = True
Exit For
End If
Next
If resourceFound Then
'--- Attach the file to resource
resourceItem.vC.CheckOut ""
Set testResourceStorage = resourceItem
testResourceStorage.UploadResource fileParentFolderPath, False
resourceItem.vC.CheckIn "Automated check-in by utility" & Now
Else
oFile.WriteLine ("Recently added new resource not found on ALM.Try again later.")
Exit Sub
End If
Else
resourceItem.vC.CheckOut ""
Set testResourceStorage = resourceItem
testResourceStorage.UploadResource fileParentFolderPath, False
resourceItem.vC.CheckIn "Automated check-in by utility" & Now
End If
Set resourceFolderFactory = Nothing
Set resourceFolder = Nothing
Set resourceFactory = Nothing
Set currResourceList = Nothing
Exit Sub
Errhandler:
MsgBox("Error Executing - `CreateNewResource` ; Error Uploading file " & fileName)
Exit Sub
End Sub