R. E. Cook
RunningShoes Library for WinRunner
Custom WinRunner Functions
and Utilities, to Your Specs
A Random Collection of WinRunner Solutions
Creating DLLs for WinRunner
(Mercury Interactive's Worldwide Users Conference 2000)
WinRunner constants in the data
We often use WinRunner's constants in the data table. For the sake of clarity, best practices dictate spelling out the name of the constant in the table instead of its value.
For example, with a column of TRUE/FALSE values, the table will be more clear if we use TRUE instead of 1, and FALSE instead of 0. Clarity
is especially important if the data table is to be maintained by anyone who is
not a WinRunner user.
However, WinRunner reads the data table entries as strings ("TRUE" or "FALSE") instead of
defined-constant values. To get around this, use the eval() statement.
The code is available in a text file to avoid the format mangling that browsers tend
to do to normal pages. View DdtConstants.txt.
Enter the case in the table, using TRUE or FALSE as strings.
Read the string from the table.
Convert the string to its value, using eval().
The syntax of the eval statement is critical. The second time the term constant
appears in the statement it is NOT within quotes.
## Loop through data table test cases.
for(table_row = 1; table_row <= row_count; table_row++)
## Set the current table row.
rc = ddt_set_row(table, table_row)
## Read the constant from the table, as a string. # constant = "TRUE"
constant = ddt_val(table, "CONSTANT");
## Convert the constant to its value. # constant = 1
if(constant != "")
eval("constant = " & constant & ";");
## Continue with the test case.
Note that the case must contain an entry for the constant. Otherwise, WinRunner will stop with the message:
constant = ;
To avoid that error message, test whether the constant is a null string before
Be sure to document the eval() statement, what it does and why it is used, or the clarity gained in the table will be lost in the script. The eval() statement can be
confusing, so it must always be well documented.