Real (%REAL) Macro

Applies to ReadyAPI 3.51, last modified on March 21, 2024

The Real macro is used to insert real numbers into the strings generated by a data source using the Custom String data generator.

The macro is an analog of the Real data generator.

Syntax

The macro has the following syntax:

%REAL(MinValue, MaxValue, GenerationMode, Increment, DecimalDigits)

Parameters

MinValue and MaxValue

Specify the lower and upper bounds of actual numbers to be generated.

Note: The value of the MaxValue parameter must be greater than or equal to the value of the MinValue parameter. Both parameters can be specified as an integer or as an actual number. Default values: MinValue = -102.500 and MaxValue = 102.500.

Generation Mode

Specifies the generation mode.

  • True – If this mode is used, ReadyAPI generates a sequence of values that will start from the value of the MinValue parameter. The increment value of the sequence is specified by the Increment parameter.

  • False – Default. If this mode is used, ReadyAPI generates random actual number values within the specified range.

The parameter is case-insensitive. ReadyAPI considers any string (even strings without symbols) as the False value. The percent (%) and closing parenthesis symbols are service symbols, so avoid using them while specifying the parameter. Otherwise, it causes errors.

Increment

Specifies an increment value for the generated sequence. The default value of the parameter is 2.50.

Note: If you want to generate a descending sequence, you need to specify a negative value for this parameter. You can also specify an actual number as the value of this parameter.
This parameter is used only with the sequential generation mode, but you have to specify the parameter even if you use the random generation mode.

DecimalDigits

Specifies the number of decimal digits in generated numbers. If you want to generate integer numbers only, you can either specify 0 as the value of this parameter or use the Integer macro. The default value of the parameter is 3.

Examples

The following example demonstrates how to use the Real macro:

  • %REAL(-102.5, 102.5, true, 5.125, 3)

    Example: Real macro in Data Generator

    Click the image to enlarge it.

    Generates a sequence of values starting from -102.5 with the increment value of 5.125. The maximum number of the generated values’ decimal digits is 3.

  • %REAL(-102.55, 102.55, true, 2, -5.05)

    Generates a sequence of values starting from 102.55 with the increment value of -5.125. The maximum number of the generated values’ decimal digits is 2.

  • %REAL(-100.5, 100.5,, 5.125, 2)

    Generates a random collection of values from -100.5 to 100.5. The maximum number of the generated values’ decimal digits is 2. In this case, the value of the Increment parameter (5.125) is omitted.

  • %REAL(-10.5, 10.5, false, 1) <- Invalid value

    The Increment parameter is missing, 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

Real Generator
Custom String Generator
Macro Reference

Highlight search results