Silktest Question 8 : If I get an exception during executing DB_Connect, how do I know exactly what kind of exception it is?

The easiest way to handle exception is to wrap the DB_Connect call in a do..except, for example :

[-] do
[ ] Print ("MSSQL : dsn={sDsn};UID={SQL_User};PWD={SQL_Pwd}")
[ ] hdbc = DB_Connect ("dsn={sDsn};UID={SQL_User};PWD={ SQL _Pwd}")
[-] except
[-] ResOpenList ("Unable to connect to the DSN '{sDsn}' for the reasons below")
[ ] ExceptLog ()
[ ] ResCloseList()

Keep it generic. There could be huge number of reasons why the connection might fail, so checking for particular failure modes isn't appropriate here.

ExceptLog() will return the ODBC error number and text, QA engineer or Test Developer could parse the error message and programmatically respond depending on the error. Be aware though that the errors will be RDBMS specific.

No comments:

SilkTest interview questions for QA Testers