zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    记录一些笔记~
    JS里的居民们7-对象和数组转换
    JS里的居民们6-数组排序
    JS里的居民们5-数组(栈)
    MySQL设置当前时间为默认值的方法
    session过期问题
    MyIsam和InnoDB的区别
    ajax请求 json格式和数组格式总结
    wamp 2.5 开放访问权限和设置虚拟域名
    checkbox属性checked="checked"通过js已设置,但是不勾选
  • 原文地址:https://www.cnblogs.com/testware/p/2010008.html
Copyright © 2011-2022 走看看