background image
<< Testcase - BOOLEAN value | Testcase - Using a main function in the script >>
Testcase - Passing data to a testcase
<< Testcase - BOOLEAN value | Testcase - Using a main function in the script >>
User's Guide
191
8 G
ENERALIZING
A
T
ESTCASE
Using data-driven testcases
Then we modified the declaration of the testcase so that it is passed a record
of type
SEARCHINFO
:
testcase FindTest (SEARCHINFO Data)
Note that the record variable name (Data) is preceded by the record type
name (
SEARCHINFO
).
Finally, we revised the testcase to use the defined data:
testcase FindTest (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 ()
Find.Cancel.Click ()
DocumentWindow.Document.VerifySelText ({Data.sExpected})
TextEditor.File.Close.Pick ()
MessageBox.No.Click ()
Note that the command that checks the Case Sensitive check box has been
changed to use the SetState method instead of the recorded Check method, so
that it can receive the
BOOLEAN
parameter bCase.
Note also that the following statement in the rewritten testcase uses the
{}
operator (list constructor operator).
DocumentWindow.Document.VerifySelText({Data.sExpected})
This is because the VerifySelText command expects a list when verifying a
multi-line text field, not a single value.
Note See the online Help for information on any of the 4Test syntax
features used in this section.
What's next
Once you have defined your data-driven testcase, you need to pass data to it,
as described next.
Passing data to a testcase
Once you have defined your data-driven testcase, you pass data to it, as
follows:
·
If you are not using QA Organizer, you pass data from a script's main
function, as described in this section.