background image
<< Testcase - Using FileReadInfo to read external data | Testcase - Testing applications >>
Testcase - The VerifyValue method
<< Testcase - Using FileReadInfo to read external data | Testcase - Testing applications >>
194
User's Guide
8 G
ENERALIZING
A
T
ESTCASE
Using data-driven testcases
type SEARCHINFO is record
STRING
sText
// Text to type in document window
STRING
sPos
// Starting position of search
STRING
sPattern
// String to look for
BOOLEAN bCase
// Case-sensitive or not
STRING
sDirection // Direction of search
STRING
sExpected
// The expected match
STRING
sMessage
// The expected message in message box
testcase FindInvalidData (SEARCHINFO Data)
TextEditor.File.New.Pick ()
DocumentWindow.Document.TypeKeys (Data.sText + Data.sPos)
TextEditor.Search.Find.Pick ()
Find.FindWhat.SetText (Data.sPattern)
Find.CaseSensitive.SetState (Data.bCase)
Find.Direction.Select (Data.sDirection)
Find.FindNext.Click ()
MessageBox.Message.VerifyValue (Data.sMessage)
MessageBox.OK.Click ()
Find.Cancel.Click ()
TextEditor.File.Close.Pick ()
MessageBox.No.Click ()
The VerifyValue method call in this testcase verifies that the message box
contains the correct string. For example, the message should be "Cannot find
Ca" if the user enters
Ca
into the Find dialog and the document editing area
does not contain this string.
Using do...except to
handle an exception
The VerifyValue method, like all 4Test verification methods, raises an
exception if the actual value does not match the expected (baseline) value.
When this happens, SilkTest halts the execution of the testcase and transfers
control to the recovery system. The recovery system then returns the
application to the base state. (For more on the recovery system, see Chapter
15, "Understanding the Recovery System".)
However, suppose you don't want SilkTest to transfer control to the recovery
system, but instead want to "trap" the exception and handle it yourself. For
example, you might want to log the error and continue executing the testcase.
To do this, you can use the 4Test do...except statement and related
statements, which allow you to handle the exception yourself.
For more information, see Chapter 9, "Handling Exceptions".