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

  • 相关阅读:
    (转) 网络流之最大流算法(EdmondsKarp)
    如何在面试中发现优秀程序员
    Java中Volatile关键字详解
    比AtomicLong还高效的LongAdder 源码解析
    AtomicInteger的用法
    synchronized详解
    Java内部锁的可重用性(Reentrancy)
    Java可重入锁
    关于原生javascript的this,this真是个强大的东东
    js时间戳怎么转成日期格式
  • 原文地址:https://www.cnblogs.com/testware/p/2010008.html
Copyright © 2011-2022 走看看