background image
<< Testcase - Using data-driven testcases | Testcase - Passing data to a testcase >>
Testcase - BOOLEAN value
<< Testcase - Using data-driven testcases | Testcase - Passing data to a testcase >>
190
User's Guide
8 G
ENERALIZING
A
T
ESTCASE
Using data-driven testcases
Creating a data-driven testcase
Procedure To create a data-driven testcase:
1
Record a testcase that tests a single combination of data.
2
Identify the data type of each recorded data value. Data values appear
inside the parentheses at the end of a 4Test statement.
3
Define a record data type for the data being factored out of the testcase.
This type definition can be placed at the top of the script file or in the test
frame.
4
Add a record variable to the testcase's list of parameters. The list of
parameters is specified between the parentheses after the testcase name.
5
Replace each data value in the testcase with the appropriate field from
the record. In 4Test, as in other languages, fields in records are indicated
with the dot (.) operator.
Example
The following example shows how to generalize the testcase shown above to
make it data-driven.
First, we analyzed the testcase to see what data it used. The testcase has five
recorded
STRING
values:
·
Test Case
·
<HOME>
·
Case
·
Down
·
Case
Next, we defined a record that consisted of the data elements used by the
testcase:
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
Note that the record contains an additional data value, a
BOOLEAN
value that
indicates whether or not to check the Case Sensitive check box.