机器人框架和 HPQC 集成

Robot Framework and HPQC integration

我正在尝试使用 VAPI-XP 将 HP Application Lifecycle Management (HP ALM)Robot Framework 集成 HP ALM 中的工具。我想知道你们中有没有人以前尝试过这个,如果有请分享你的方法。

此致, 乌尼

我正在 post 编写我为我的项目创建的脚本(将在 VAPI-XP Testscript 窗格中编写的 VBScript),以将 Robot FW 与 Quality Center 集成。这将创建一个动态批处理命令行文件,当脚本从 QC 触发时执行机器人框架脚本,并且 post RF html 结果文件作为 QC 测试 运行 实例的附件。

您可以浏览脚本并根据需要进行修改。

谢谢, 达莫达兰 B

' ----------------------------------------------------
' Main Test Function
' Debug - Boolean. Equals to false if running in [Test Mode] : reporting to Quality Center
' CurrentTestSet - [OTA COM Library].TestSet.
' CurrentTSTest - [OTA COM Library].TSTest.
' CurrentRun - [OTA COM Library].Run.
' ----------------------------------------------------
Sub Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun)
  On Error Resume Next
  TDOutput.Clear

  ' Run Test
  strMainDir = "C:\Robot-QC"
  strTestDir = strMainDir & "\Execution"
  strBatchFileDir = strTestDir & "\BatchFiles"
  strResultDir = strTestDir & "\Results"

  strTestName = "TestCase1"
  strResultPath = strResultDir & "\" & strTestName & "_Res"
  strExecutionLogPath = strResultPath & "\ExecutionLog.txt"

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  If objFSO.FolderExists(strResultPath) Then
     objFSO.DeleteFolder strResultPath, True
  End If
  objFSO.CreateFolder strResultPath

  'If Execution Directly From QC, Creates Test Batch File
  If Not objFSO.FileExist(strBatchFileDir & "\" & strTestName & ".bat")Then
     'Write Batch File for Test
     Set objTestBatchFile = objFSO.OpenTextFile(strBatchFileDir & "\" & strTestName & ".bat", 2, True)
     objTestBatchFile.WriteLine "cd " & strTestDir
     objTestBatchFile.WriteLine "pybot -t " & strTestName & " --outputdir Results\" & strTestName & "_Res " & "TestCases.txt"
     objTestBatchFile.Close
     Set objTestBatchFile = Nothing
  End If

  XTools.run strBatchFileDir & "\" & strTestName & ".bat", "", -1
  XTools.Sleep 1000

  ' Update Run Status
  strTDOutPut = Replace(TDOutput.Text, " ", "")
  If InStr(1, strTDOutPut, strTestName & "|PASS|") = 0 Then
     CurrentRun.Status = "Failed"
     CurrentTSTest.Status = "Failed"
  End If
  'Log Command Prompt Output
  Call Log_Output(objFSO,strExecutionLogPath)

  'Upload Result Files
  Set objFolder = objFSO.GetFolder(strResultPath & "\")
  Set objFiles = objFolder.Files

  For Each oFile In objFiles
       Set objRunAttach = CurrentRun.Attachments
       Set newAtt = objRunAttach.AddItem(Null)
       newAtt.FileName = strResultPath & "\" & oFile.Name
       newAtt.Type = 1
       newAtt.Post
       newAtt.Refresh
  Next

  Set newAtt = Nothing
  Set objRunAttach = Nothing
  Set objFiles = Nothing
  Set objFolder = Nothing
  Set objFSO = Nothing

  Err.Clear
  On Error Goto 0
End Sub

Sub Log_Output(objFSO,strExecutionLogPath)
   Set objOutputFile = objFSO.OpenTextFile(strExecutionLogPath, 2, True)
   objOutputFile.Write TDOutput.Text
   objOutputFile.Close
   Set objOutputFile = Nothing
End Sub