|
Data-Driven Tests
Data for Data-Driven tests is stored in a *.CSV File.
The first row in a CSV file contains the names, each one surrounded by { },
that should be used in the calling script to reference the values in the
corresponding column.
Example:
{first_name},{last_name}
James,Bond
Johnny,Bravo
The calling script uses the same {} convention to reference the names.
Each {name} will be replaced by data that appears in the *.csv file.
Example:
setVar counter=+1 label=START_HERE ;
setDataIndex value=:{counter} ;
_doif counter=<2 ;
kbText id=1 ktext='Name: {first_name} {last_name}';
_goto label=START_HERE ;
_endif ;
would print:
Name: James Bond
on the first iteration and
Name: Johnny Bravo
on the second iteration.
Note: if the looping continued, the data would be read in again starting at
the beginning of the *.csv file.
The constant {_COUNT_} is also available and will resolve to a
number representing the repeat count of the script run.
It is independent of any CSV file.
A set of timestamps is also available:
{_TIMESTAMPNOW1_},
{_TIMESTAMPNOW2_},
{_TIMESTAMPNOW3_},
{_TIMESTAMPFIX1_},
{_TIMESTAMPFIX2_},
{_TIMESTAMPFIX3_},
Each will resolve to a real timestamp using the format specified for the
corresponding setting in the Playback Options Dialog.
These values are independent of any CSV file.
Warning: if a TestSmith variable uses the
same name as a .csv file column name or one of the constants mentioned
here the variable will take precedence.
See the example csv files
smith1.csv and smith2.csv in the /Data directory
and the sample script datadriver.smith in the /Scripts directory
for examples of how data is formatted, referenced and used.
See the SET command and the
DATA and
ROOTDIR directives for
further information on loading and setting a data file.
Note:
CSV (comma separated values) files are recognized as spreadsheet
files by Microsoft Excel. They can also be opened and edited in a simple
text editor such as Notepad.
|