|Quoting and escaping special characters|
A common problem for most complex systems is the treatment of characters with a special meaning. A typical example are blanks in filenames. To specify such filenames on the command line, they need to be protected either by using double quotes or by escaping the blanks with a backslash character ('\').
Since QF-Test makes use of special characters in various contexts while reading arbitrary strings from the SUT that may contain any character, some kind of quoting mechanism is unavoidable. That QF-Test runs on various operating systems and makes use of regular expressions which have their own set of special characters doesn't make things any easier. However, QF-Test attempts to keep things as simple as possible by restricting quoting to the places where it can't be avoided and by quoting all strings read from the SUT during recording correctly.
The most prominent special character for QF-Test is the '$' sign used for variable expansion. Variable syntax is applicable in almost all attributes. If you need a literal '$' character in an attribute value you have to double it.
Other special characters are used only in a few places and must be quoted only there. These are the '#' character used for 'Procedure' and 'Component' access across suites and the characters '@', '&' and '%' for the special syntax for sub-item access. Since these are used as separators they cannot be escaped by doubling them, so QF-Test follows the convention to use the backslash '\' as escape character which turns the backslash itself into another special character. To avoid quoting-hell with Windows filenames, QF-Test only uses quoting where the above characters are used and even there a single backslash that is not followed by a special character is interpreted literally.
To be precise, you have to escape the characters '#' and '\' in the 'Procedure name' attribute of a 'Procedure call' and the characters '#', '\', '@', '&' and '%' in the attributes 'QF-Test component ID' of events and checks as well as the 'Primary index' and 'Secondary index' of an 'Item'. Remember that the backslash is also used as the escape character for regular expressions, so to get a literal '\' into a regexp for a sub-item, you first need to escape it for the regexp itself, i.e. "\\", then escape these for QF-Test leading to "\\\\".
There is one more special case that requires a special character and
corresponding quoting. This is the '/' character used as separator
for tree path sub-items of a
JTree component. Thus the
'/' must be quoted if and only if you need a literal / in a sub-item
JTree component. Sub-items of other components
don't require special handling.
|Last update: 06/17/2020
Copyright © 1999-2020 Quality First Software GmbH