String (%STR) Macro

Applies to ReadyAPI 3.56, last modified on November 25, 2024

The String macro is used to insert arbitrary text data into the strings generated by a data source using the Custom String data generator.

The macro is an analogue of the String data generator.

Syntax

The macro has the following syntax:

%STR(MinLength, MaxLength, Digits, Letters, PunctuationMarks, Spaces)

Parameters

MinLength and MaxLength

Specify the length of the shortest and the longest generated string respectively. The value of the MinLength parameter must be less than or equal to the value of the MaxLength parameter.

Digits, Letters, PunctuationMarks, and Spaces

Boolean parameters that specify whether ReadyAPI uses corresponding characters to generate the resulting string:

  • Digits – The generated string will contain digits.

  • Letters – The generated string will contain letters.

  • PunctuationMarks – The generated string will contain punctuation marks.

  • Spaces – The generated string will contain spaces.

The parameters are case-insensitive.
You need to specify at least one of these parameters as True. Otherwise, ReadyAPI cannot generate a custom sting.

Examples

The following examples demonstrate how to use the String macro:

  • %STR(1, 8, True, true, TRUE, TrUe)

    Example: String macro in Data Generator

    Click the image to enlarge it.

    Generates strings of 1 – 8 characters that contain letters, digits, spaces, and punctuation marks.

  • %STR(4, 10, False, True, True, False)

    Generates strings of 4 – 10 characters that contain letters and punctuation marks only. Each of the generated values will be repeated 3 times.

  • %STR(8, 3, True, True, True, True) <- Invalid value

    The value of the MinLength parameter is greater than the value of the MaxLength parameter, so ReadyAPI will not parse the custom string.

  • %STR(7, 7, True,,,True)

    Generates strings of 7 characters that contain spaces and digits only.

  • %STR(1, True, False, True, False) <- Invalid value

    The value of MinLength or MaxLength is missing, so ReadyAPI will not parse the custom string.

  • %STR(1, 10, False, False, False, False) <- Invalid value

    There are no characters to generate a string, so ReadyAPI will not parse the custom string.

Remarks

For more information on adding macros to custom strings, see About Custom String Generator.

For more information on general rules used for specifying macro parameters, see Custom String Generator Rules.

See Also

Data Generator
Custom String Generator
Macro Reference

Highlight search results