Random
libraryGenerates random test data: whole numbers, letter strings and IBANs. Values come from a general purpose random generator and are not suitable for passwords or tokens.
- Kind Library, a global in every script
- Category Utilities
- Functions 3
Functions
number()
Section titled “number()”Random.number(max: number)→numberRandom.number(min: number, max: number)→number Returns a random whole number. With one argument the range is 0 up to and including `max`; with two arguments it is `min` up to and including `max`. Arguments are cut to whole numbers. Throws when `min` is greater than `max`.
Parameters
-
minnumber - Lowest possible value
-
maxnumber - Highest possible value
Returns
Example runs in CI
print(Random.number(1, 100))print(Random.string(8))string()
Section titled “string()”Random.string(count: number)→string Returns a random string of exactly `count` letters (a-z and A-Z, no digits or symbols). Throws for a negative count.
Parameters
-
countnumber - Number of letters; 0 gives an empty string
Returns
iban()
Section titled “iban()”Random.iban(code: string, bank: string)→string Returns a random IBAN with valid check digits and a random account number, written without spaces. The bank code must have the format of the country: four letters for `NL` (`ABNA`), eight digits for `DE`. Throws when the country code is unknown or the bank code does not fit the country.
Parameters
-
codestring - Two-letter country code in capitals, like `NL` or `DE`
-
bankstring - Bank code in the format of that country, like `ABNA` for NL
Returns
Example runs in CI
print(Random.iban("NL", "ABNA"))