Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel Can';t将多个测试用例上载到HP ALM_Excel_Vba_Hp Quality Center_Hp Alm - Fatal编程技术网

Excel Can';t将多个测试用例上载到HP ALM

Excel Can';t将多个测试用例上载到HP ALM,excel,vba,hp-quality-center,hp-alm,Excel,Vba,Hp Quality Center,Hp Alm,我的问题是当前代码只上传一个测试用例,我无法添加多个测试用例,因为测试步骤的数量是动态的(见附图),因此,我不知道每个测试用例将在哪一行结束,以便将其添加到代码中,以便自动化整个过程,例如,如果我要上传10个测试用例 我将非常感谢您的帮助,想出一种方法来创建一个循环,它可以集成所有内容,并允许用户根据需要上传尽可能多的测试用例 干杯 我已经上传了一个包含所有步骤和预期结果的测试用例 Sub upload_test_cases() Dim wd, CConnection, sProject, s

我的问题是当前代码只上传一个测试用例,我无法添加多个测试用例,因为测试步骤的数量是动态的(见附图),因此,我不知道每个测试用例将在哪一行结束,以便将其添加到代码中,以便自动化整个过程,例如,如果我要上传10个测试用例

我将非常感谢您的帮助,想出一种方法来创建一个循环,它可以集成所有内容,并允许用户根据需要上传尽可能多的测试用例

干杯

我已经上传了一个包含所有步骤和预期结果的测试用例

Sub upload_test_cases()

Dim wd, CConnection, sProject, sTestPlanPath, TestFolderPath, strNodeByPath

'qcURL = InputBox("Please enter ALM URL", "", "http://url:8080/qcbin")
qcURL = "http://url:8080/qcbin/"
If qcURL = "" Then
  MsgBox ("ALM URL cannot be blank")
  Exit Sub
End If

'sDomain = InputBox("Please enter your Domain" & vbNewLine & "Eg:CORE_SYSTEMS", "", "CORE_SYSTEMS")
sDomain = ""
If sDomain = "" Then
  MsgBox ("DomainName cannot be blank")
  Exit Sub
End If

'sProject = InputBox("Please enter your ProjectName" & vbNewLine & "Eg:RADC;GCM(As per ALM Project)", "", "GCM")
sProject = ""
If sProject = "" Then
  MsgBox ("ProjectName cannot be blank")
  Exit Sub
End If

sUser = InputBox("Please enter your Username" & vbNewLine & "Eg:MSID", "", "")
'sUser = ""
If sUser = "" Then
  MsgBox ("UserName cannot be blank")
  Exit Sub
End If

sPass = InputBox("Please enter your Password", "", "")
'sPass = ""

'sFolderpath = InputBox("Please enter your ALM Folderpath" & vbNewLine & "<Subject\FolderStructure>", "")
'sFolderpath = "Subject\Folder_Name"

'If sFolderpath = "" Then
 ' MsgBox ("FolderPath cannot be blank")
  'Exit Sub
'End If

Set QCConnection = CreateObject("TDApiOle80.TDConnection")

QCConnection.InitConnectionEx qcURL
QCConnection.ConnectProjectEx sDomain, sProject, sUser, sPass


Set tsf = QCConnection.TestFactory
Set trmgr = QCConnection.TreeManager
Set subjectfldr = trmgr.NodebyPath("Subject")
Worksheets("Sheet1").Select
' read the main and sub folder names
Set folder = Worksheets("Sheet1").Cells(2, 1)
Set subfolder = Worksheets("Sheet1").Cells(2, 2)

On Error Resume Next
' create main folder
Set trfolder = subjectfldr.AddNode(Worksheets("Sheet1").Cells(2, 1))
trfolder.Post

Set subjectfldr = trmgr.NodebyPath("Subject\" & folder)
'create subfolder if specified
If Not subfolder = "" Then
Set trfolder = subjectfldr.AddNode(subfolder)
trfolder.Post
End If

'reset error handling
On Error GoTo 0

If subfolder = "" Then
Set trfolder = trmgr.NodebyPath("Subject\" & folder)
Else
Set trfolder = trmgr.NodebyPath("Subject\" & folder & "\" & subfolder)
End If


' now create a test case
Set sampleTest = trfolder.TestFactory.AddItem(Null)
' set mandatory values
sampleTest.Field("TS_NAME") = Worksheets("Sheet1").Cells(2, 3) ' Test Case Name
sampleTest.Field("TS_DESCRIPTION") = Worksheets("Sheet1").Cells(2, 4) ' Project
sampleTest.Field("TS_RESPONSIBLE") = Worksheets("Sheet1").Cells(2, 8) ' Designer[![enter image description here][1]][1]


sampleTest.Post
' create test steps
Set dsf = sampleTest.DesignStepFactory
Set stepList = dsf.Newlist("[empty]")

Dim RowCount As Integer

' loop through all the steps
LastRow = Range("F2", Range("F2").End(xlDown)).Rows.Count
For i = 2 To (LastRow + 1)
Set dstep = dsf.AddItem(Null)
dstep.StepName = Worksheets("Sheet1").Cells(i, 5) ' Step Name
dstep.StepDescription = Worksheets("Sheet1").Cells(i, 6) ' Step Description
dstep.StepExpectedResult = Worksheets("Sheet1").Cells(i, 7) ' Step Expected Results
'stepList.Add (dstep)
'sampleTest.Post
dstep.Post
Next i


Set DesignStepFactory = Nothing
Set TestFactory = Nothing
Set TreeManager = Nothing
    
'Disconnect from QC
QCConnection.Disconnect

'Logout the QC Session
QCConnection.Logout
QCConnection.ReleaseConnection

End Sub

Sub-upload\u test\u cases()
Dim wd、C连接、存储项目、sTestPlanPath、TestFolderPath、strNodeByPath
'qcURL=InputBox(“请输入ALM URL”,“”,“http://url:8080/qcbin")
qcURL=”http://url:8080/qcbin/"
如果qcURL=“”,则
MsgBox(“ALM URL不能为空”)
出口接头
如果结束
'sDomain=InputBox(“请输入您的域”&vbNewLine&“例如:核心系统”、“核心系统”)
sDomain=“”
如果sDomain=“”,则
MsgBox(“域名不能为空”)
出口接头
如果结束
'sProject=InputBox(“请输入您的项目名称”&vbNewLine&“例如:RADC;GCM(根据ALM项目)”,'',“GCM”)
sProject=“”
如果sProject=“”,则
MsgBox(“项目名称不能为空”)
出口接头
如果结束
sUser=InputBox(“请输入您的用户名”&vbNewLine&“例如:MSID”、“”、“”)
'sUser=“”
如果sUser=”“,则
MsgBox(“用户名不能为空”)
出口接头
如果结束
sPass=InputBox(“请输入您的密码”、“”、“”)
'sPass=“”
'sFolderpath=InputBox(“请输入您的ALM Folderpath”&vbNewLine&“”,“”)
'sFolderpath=“主题\文件夹\u名称”
'如果sFolderpath=”“,则
'MsgBox(“FolderPath不能为空”)
“出口接头
"完"
设置QCConnection=CreateObject(“TDApiOle80.TDConnection”)
QCConnection.InitConnectionEx qcURL
QCConnection.ConnectProjectEx sDomain、sProject、sUser、sPass
设置tsf=QCConnection.TestFactory
设置trmgr=QCConnection.TreeManager
设置subjectfldr=trmgr.NodebyPath(“主题”)
工作表(“表1”)。选择
'读取主文件夹和子文件夹名称
设置文件夹=工作表(“Sheet1”)。单元格(2,1)
设置子文件夹=工作表(“Sheet1”)。单元格(2,2)
出错时继续下一步
'创建主文件夹
设置trfolder=subjectfldr.AddNode(工作表(“Sheet1”)。单元格(2,1))
trfolder.Post
设置subjectfldr=trmgr.NodebyPath(“Subject\”&文件夹)
'如果指定,则创建子文件夹
如果不是子文件夹=“则
设置trfolder=subjectfldr.AddNode(子文件夹)
trfolder.Post
如果结束
'重置错误处理
错误转到0
如果子文件夹=“则
设置trfolder=trmgr.NodebyPath(“主题\”和文件夹)
其他的
设置trfolder=trmgr.NodebyPath(“主题\文件夹和子文件夹”)
如果结束
'现在创建一个测试用例
设置sampleTest=trfolder.TestFactory.AddItem(Null)
'设置强制值
sampleTest.Field(“TS_NAME”)=工作表(“Sheet1”).Cells(2,3)的测试用例名称
sampleTest.Field(“TS_DESCRIPTION”)=工作表(“Sheet1”).单元格(2,4)”项目
sampleTest.Field(“TS_RESPONSIBLE”)=工作表(“Sheet1”).Cells(2,8)“设计器[![在此处输入图像描述][1]][1]
抽样测试
'创建测试步骤
设置dsf=sampleTest.DesignStepFactory
Set stepList=dsf.Newlist(“[empty]”)
将行计数设置为整数
“循环完成所有步骤
LastRow=范围(“F2”,范围(“F2”).End(xlDown)).Rows.Count
对于i=2到(最后一行+1)
设置dstep=dsf.AddItem(空)
dstep.StepName=工作表(“表1”)。单元格(i,5)的步骤名称
dstep.StepDescription=工作表(“表1”)。单元格(i,6)的步骤说明
dstep.StepExpectedResult=工作表(“表1”)。单元格(i,7)的步骤预期结果
'stepList.Add(dstep)
“sampleTest.Post
dstep.Post
接下来我
设置DesignStepFactory=Nothing
设置TestFactory=Nothing
设置TreeManager=Nothing
'断开与QC的连接
连接,断开
'注销QC会话
QCConnection.Logout
QCConnection.ReleaseConnection
端接头
用户应该能够根据excel电子表格表1中添加的数据,根据需要上传尽可能多的测试用例

我知道有一个Excel外接程序可以执行此操作,但是运行宏并自己设置所有内容要容易得多,也方便得多,这就是为什么我尝试使用此特定宏的原因


您好,我不确定是否完全理解您的问题。请您编辑您的问题并添加一个逐步的配方,您到底尝试了什么?我通常的方法是设计meta Excel文件,跟踪每个测试用例的测试用例步骤,并为标准HP ALM Excel插件生成一个文件(内部没有任何VBA)。您好,我不确定是否完全理解您的问题。请您编辑您的问题并添加一个逐步的配方,您到底尝试了什么?我通常的方法是设计meta Excelfile,它跟踪每个测试用例的测试用例步骤,并为标准的HP ALM Excel插件生成一个文件(内部没有任何VBA)。