The Custom String generator is used for generating strings using the predefined template. This generator type helps you populate the desired Excel file or TestComplete Table variable with various custom strings and then use this data in your tests.
To activate the Custom String generator, do the following:
In the Generate Values dialog, select Custom String from the Data Generator list.
Activate any user-defined generator based on the Custom String standard generator as it is described above.
After you have selected the Custom String generator, you are offered to specify some additional parameters for the generated data. The parameters are:
A string of macros, text, format specifiers and regular expressions that will be used to generate values. The default value of this parameter is
%INT(1, 2147483647, 1) %NAME(ANY, FULL) lives in %CITY.
You use macros to generate and insert values of various types into the resulting string. Macro names start with the
% character. You can either type the macro name, or click Add Macro and choose the desired macro from the drop-down list. Some macros may require that you to specify parameters.
Regular expressions help you insert specific text parts into the generated strings. They are used only when the Use regular expressions check box is selected. If it is clear, TestComplete treats the regular expression syntax as ordinary text.
Important: If you use regular expressions and you need special characters to be treated literally, precede them with backslashes ( “
\” ) in the Value string. Special characters are brackets ( “
[” and “
]” ), parentheses ( “
(” and “
)” ), quotes ( " ) and some other characters. See Characters That Require Special Handling.
Also, you can format the generated values using special format specifiers. For instance, you can use the following macro to generate a sequence of integer values with the specified minimum length (3 characters) --
%0.3d%INT(1, 100, 3). If the length of the generated value is less than the specified constant, TestComplete adds the needed number of leading zeros to the value. For more information, see Format Specifiers.
For complete information on specifying custom string values, see Custom String Generator Rules.
Use regular expressions
Optional parameter. Specifies whether the Value string contains regular expressions. If this option is enabled, TestComplete retrieves regular expressions from the Value field and process them. Otherwise, the contents of the Value field are treated as a string containing macros, literals and format specifiers only. For information on the supported expressions, see Custom-String Generator - Supported Regular Expressions.
If you use regular expressions and you need special characters to be treated literally, precede them with backslashes in the Value string (see above).
By default, the parameter is disabled, so the regular expressions are not used. However, if you select a macro that is specified using regular expressions from the Add Macro list, the Use regular expressions check box is selected automatically.
Duplicate each value … time(s)
Specifies how many times each generated value will be duplicated. The default value of the parameter is False.
After all of the required parameters are specified, TestComplete automatically shows the sample sequence of generated values in the Sample field.
Also, you can discard all the changes you made in the generator’s parameters and restore the parameters set by default. For this purpose, click Set Default Values below the Sample field.
If you are going to use the Custom String generator with the specified parameters several times, it is much easier to save these parameters as a user-defined generator. For more information, see Working With User-Defined Data Generators.
For more information on basic principles used to generate custom strings with TestComplete, see Custom String Generator Rules.