• TestPartner脚本错误处理的例子


    The following test script is an example of TestPartner as well as VBA error handling:

    Sub Main()

      On Error Resume Next

      Dim oe As TOnError
      Set oe = OnError("MyErrorFunction")

      ' Attach to Program Manager Window
      Window("Program Manager Window").Attach

      ' Try to perform the bitmap select and get the return code.
      ' Since this a failure of a method, TestPartner can control
      ' the creation of the error condition using TestPartner's
      ' error mechanism.
      Dim b As Boolean
      b = Window.BitmapSelect("MetapadIcon")
      MsgBox "Return from BitmapSelect = " & CStr(b)

      ' This statement will require the VBA version of the On Error
      ' handler because the Window() statement returns an object that
      ' will be used to Attach.  If the object is not created because
      ' the attach name could not be found in the object map, VBA
      ' generates an error so the message has to be trapped.
      On Error GoToObjectErrorSub
      b = Window("this object map does not exist").Attach
      MsgBox "Return from Window.Attach = " & CStr(b)

    Exit Sub

    ObjectErrorSub:

      ' Display and/or handle VBA error
      MsgBox "Err.Number = " & CStr(Err.Number) & vbCrLf & _
      "Err.Source = " & Err.Source & vbCrLf & _
      "Err.Description = " & Err.Description
      Resume Next

    End Sub

    Function MyErrorFunction() As tpOnErrorType

      ' Display an error
      MsgBox "Message = " & Error.Message & vbCrLf & _
      "Function = " & Error.Function & vbCrLf & _
      "SourceFile = " & Error.SourceFile & vbCrLf & _
      "SourceLine = " & CStr(Error.SourceLine)

      ' Tell TestPartner that it should execute the next statement
      MyErrorFunction = tpResumeNext

    End Function

  • 相关阅读:
    深入理解幂等性(转)
    Mysql数据库表结构设计准则
    nodejs以对象做对象的key导致value一直被覆盖
    数组常用方法
    css选择器总结
    CSS 选择器权重计算规则
    ElementUI select
    linux-sed命令
    vue 组件数据传递:
    vue视频: 自定义指令 && 拖拽 && 自定义键盘信息
  • 原文地址:https://www.cnblogs.com/testware/p/2010008.html
Copyright © 2020-2023  润新知