Rules for finding and replacing
The following table shows how
Silk Test Classic works when it finds and replaces values in your scripts.
Value Found in Script
|
Database Column Type
|
Replaced by
|
Tip
|
STRING
|
STRING
|
Column
|
|
|
INTEGER
|
Str(Column)
|
5
|
|
REAL
|
Str(Column,NULL,2)
|
1, 3, 4, 5
|
|
BOOLEAN
|
Str(Column)
|
8
|
|
DATETIME
|
[STRING]Column
|
7
|
|
|
|
|
INTEGER
|
STRING
|
Val(Column)
|
|
|
INTEGER
|
Column
|
|
|
REAL
|
Column
|
1, 6
|
|
BOOLEAN
|
(not allowed)
|
|
|
DATETIME
|
(not allowed)
|
|
|
|
|
|
REAL
|
STRING
|
Val(Column)
|
|
|
INTEGER
|
Column
|
6
|
|
REAL
|
Column
|
|
|
BOOLEAN
|
(not allowed)
|
|
|
DATETIME
|
(not allowed)
|
|
|
|
|
|
BOOLEAN
|
STRING
|
(not allowed)
|
|
|
INTEGER
|
Column
|
2, 6
|
|
REAL
|
(not allowed)
|
|
|
BOOLEAN
|
Column
|
|
|
DATETIME
|
(not allowed)
|
|
|
|
|
|
DATETIME
|
|
|
7
|
When you are creating a data-driven test case, there are several points to note about the find and replace process. These
notes are referenced by the Rules for finding and replacing table, shown above.
- MS Excel stores integers as REALs. This means that you may see a 1 in an MS Excel cell, but the number that is stored is
actually 1.000. Whenever you replace an integer in a test case with a column designated as REAL,
Silk Test Classic displays a question similar to the following:
To ensure that
Silk Test Classic handles your data properly, additional information is needed: Will column QtyToOrder contain only INTEGER (no decimal point)
values? Click Yes to treat that column's values as INTEGER; click No to continue to treat that column's values as REAL.
- Some databases (such as MS Excel) store booleans as INTEGERs. This means that you may see a TRUE in an Excel cell, but the
value that is stored is actually 1. Whenever you replace a boolean in a test case with a column designated as INTEGER ,
Silk Test Classic displays a question similar to the following:
To ensure that
Silk Test Classic handles your data properly, additional information is needed: Will column OnSale contain only BOOLEAN (TRUE/FALSE) values?
Click Yes to treat that column's values as BOOLEAN; click No to continue to treat that column's values as INTEGER.
- If you have a currency string, we recommend that you split it into two strings separated by a plus sign. The first string
should contain just the financial symbol (for example, the dollar sign or USD acronym) and the second string should contain
just the number value. When you do a find and replace, this lets you replace only the number value, not the financial symbol
or acronym. For example, do not use $123.45, instead use $ + 123.45
- When a STRING literal is replaced by a column containing REAL values, the real number is rounded to two decimal places. To
change the number of decimal places that are displayed, change the value of iDecimal in Str (table.column, NULL, iDecimal).
For example, to display 7.1234 instead of 7.12, change:
Str (table.column, NULL, 2)
to:
Str (table.column, NULL,4)
- You can replace any STRING value with a REAL or INTEGER column. However, in order to have a working sample record, the value
that is first replaced by that column should be a STRING representation of a REAL or INTEGER constant.
- In certain cases,
4Test implicitly converts one data type to another. In that case,
Silk Test Classic does not insert a conversion expression when replacing the value by the DB column reference..
- To represent a DATETIME value, in other words a
4Test DATETIME constant, you must create a STRING that specifies the date and time in the standard
4Test DATETIME (ISO) format - YYYY-MM-DD HH:MM:SS.MSMSMS. You can truncate the string at any point, as long as the last field is
complete. If you use a different format, you will cause a runtime error. Because DATETIME values found in a script are actually
STRING values, the replacement rules are the rules for STRING values.
- The conversion from STRING to BOOLEAN will cause a runtime error. The expression must be changed manually from 'Str(Column)'
to: [STRING]Column.
- A fraction is considered an INTEGER division expression, so the value inserted into the sample record is truncated to the
next lowest integer.
- If
Silk Test Classic does not insert any of the expected conversion expressions, then the
Validate Replacements setting is probably unchecked. Click
to see how
Validate Replacements is set.
- When you do a Find/Replace,
Silk Test Classic skips values contained in variable definitions. To find those values, click
to turn off
Validate Replacements. We recommend that you initialize variables after you define them; be sure to separate the variable definition and assignment
on two different lines.