Results 1 to 3 of 3
  1. #1

    where ExceptClear method can be used ?

    I am learning SilkTest on my own and therefore reading
    SilkTest help.

    After reading the description of ExceptClear() method,
    I was not able to come up with a scenario where I can use it ?

    Any ideas or real time example ?

    After posting the post ,
    I realized that since I am not asking an Interview Question, so I need to mention it.

  2. #2

    Re: where ExceptClear method can be used ?

    There are many situations where you'd want to clear the current exception and let the script continue as if nothing had gone wrong. Accessing a database is typical. You want to trap all return-codes, but of course, a row not found situation also generates a return-code. Some testcases verify that a row does not exist, and it's these situations where coding an ExceptClear is good practise: eg:
    <font class="small">Code:</font><hr /><pre>
    [ ] Print ("Connecting to Access table {sTable} using DSN {sDSN}")
    [ ] hdbc = DB_Connect("dsn={ sDSN }")
    [ ]
    [ ] lsFiles = {}
    [ ]
    [ ] sSQL = "select PayloadFileName FROM " + sTable + " ORDER BY Sequence"
    [ ]
    [ ] hstmnt = DB_ExecuteSql (hdbc, sSQL)
    [ ]
    [-] do
    [ ]
    [+] while DB_FetchNext (hstmnt,sPayloadFileName)
    [ ] ListAppend (lsFiles, sPayloadFileName)
    [ ] DB_FinishSQL (hstmnt)
    [ ]
    [-] except
    [ ] LogError ("SQL command FetchNext failed")
    [ ] LogError (StrTran (ExceptData(),"[Microsoft][Access Driver]",""))
    [ ] Print ("")
    [-] ExceptClear ()
    [ ]
    [ ] DB_Disconnect (hdbc)
    [ ]
    </pre><hr />

    In the above example, if we get a return-code back we issue a eyecatcher log message first, followed by the actual error msg. This code fragment is part of routine in which we know beforehand that it is likely that the SELECT will return an empty set, so if that's true we finish up by issuing an ExceptClear to clear the exception and let the script continue.

    Of course, we might have a bigger problem but the combination of the eyecatcher and the actual error msg provides enough information for testers to decide whether the script ran OK, or not.


  3. #3

    Re: where ExceptClear method can be used ?


    Thanks for the real-time example, it makes sense now.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:17 PM.

Copyright BetaSoft Inc.