Random values

Value expressions let you auto-generate dynamic values at runtime, based on your specifications. They help you to automate important processes and reduce test design and maintenance efforts.

With random value expressions, you can generate random numbers and strings. For example, to quickly test an overall workflow, where exact values aren't crucial. Or to test basics, such as "This particular entry field doesn't accept any value that's longer than X characters."

This topic takes you through the types of random values you can generate in your test cases.

Integer values

To generate a random integer, with a maximum of 18 digits, choose one of the following options:

  • To generate an integer without limits, use the syntax {RND[Length of random number]}.

  • To generate an integer within a certain range, use the syntax {RND[Lower limit][Upper limit]}. You can also enter negative values. The generated integer is a value that lies between the upper and lower limits, boundaries included.

Generate two types of integers.

  • {RND[7]} generates a 7-digit integer, for example 2085672.

  • {RND[-789][123]} generates an integer from -789 to 123, for example -162.

Random numbers with decimals

To generate a random number with decimals, with a maximum of 18 digits, choose one of the following options:

  • To generate a number with a defined number of digits and decimal places, use the syntax {RNDDECIMAL[Length of random number][Decimal places]}.

  • To generate a number within a certain number range with a specific number of decimal places, use the syntax {RNDDECIMAL[Decimal places][Lower limit][Upper limit]}. You can also enter negative values. The generated integer is a value that lies between the upper and lower limit, boundaries included.

Generate two types of random numbers with decimals.

  • {RNDDECIMAL[5][2]} generates a 5-digit number with two decimal places. For example, 23152.85.

  • {RNDDECIMAL[4][130][200]} generates a number from the value range 130 to 200, with four decimal places. For example, 143.4780.

Random strings

To generate a random mix of numbers and letters, with a maximum of 1024 characters, use the syntax {RANDOMTEXT[Desired string length]}.

Generate a random string that's 8 characters long.

The expression {RANDOMTEXT[8]} generates strings such as s94T2Bi5, UI0YS83W, or wg0jzJt7.

Random strings based on the time stamp

To generate a random string based on the current time stamp, use the syntax {CTMSTMP}.

Please note that the actual time stamp is not part of the resulting string. Tosca Cloud uses the time stamp and converts it to ASCII, which creates a unique ID of 16 characters.

Generate a random string based on the time stamp.

Let's say today is February 8, 2024, and it's 4.15 PM. In this case, the expression {CTMSTMP} generates strings such as 5mb629h08k7il2ri, 5mb629h0e2o6lnhs, or 5mb629h1ewbo7pqe.

Random strings based on regular expressions

To generate a random string based on Microsoft regular expressions, use the syntax {RANDOMREGEX["Regular expression"]}.

For information on the rules and syntax of regular expressions, see the Microsoft REGEX documentation.

Generate a random string based on regular expressions.

The expression {RANDOMREGEX["^[A-E][a-z]+[0-5]{4}$"]} generates a value that starts with an upper-case letter from A to E, followed by any number of lower-case letters from a to z and four digits from 0 to 5.

The ^ character marks the beginning of the line, and $ marks the end of the line.

One possible result is Aq3254.