Expressions available out of the box
Here one could find description of the expressions that are delivered with Vividus itself without any plugins required.
The expression parameters marked with bold are mandatory. |
Data generation
randomInt
Generates a random integer value between the specified origin (minInclusive
) and the specified bound (maxInclusive
).
#{randomInt($minInclusive, $maxInclusive)}
-
$minInclusive
- the least value -
$maxInclusive
- the upper bound
Expression | Result |
---|---|
|
An integer between 1 and 10 |
|
An integer between 100 and 999 |
|
An integer between -5 and 5 |
|
An integer between -5 and -2 |
|
|
String manipulations
toLowerCase
Converts an input string to lower case.
#{toLowerCase($input)}
-
$input
- any string to be converted lower case
Expression | Result |
---|---|
|
|
toUpperCase
Converts an input string to upper case.
#{toUpperCase($input)}
-
$input
- any string to be converted upper case
Expression | Result |
---|---|
|
|
capitalize
Deprecated, will be removed in VIVIDUS 0.4.0 use capitalizeFirstWord instead
|
Capitalizes an input string, changing the first character to title case. No other characters are changed.
#{capitalize($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
capitalizeFirstWord
Capitalizes an input string, changing the first character to title case. No other characters are changed.
#{capitalizeFirstWord($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
capitalizeWords
Capitalizes all the whitespace separated words in the input string. Only the first character of each word is changed.
#{capitalizeWords($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
capitalizeWordsFully
Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.
#{capitalizeWordsFully($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
uncapitalize
Deprecated, will be removed in VIVIDUS 0.4.0 use uncapitalizeFirstWord instead
|
Uncapitalizes an input string, changing the first character to lower case. No other characters are changed.
#{uncapitalize($input)}
-
$input
- any string to be uncapitalized
Expression | Result |
---|---|
|
|
uncapitalizeFirstWord
Uncapitalizes an input string, changing the first character to title case. No other characters are changed.
#{uncapitalizeFirstWord($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
uncapitalizeWords
Uncapitalizes all the whitespace separated words in the input string. Only the first character of each word is changed.
#{uncapitalizeWords($input)}
-
$input
- any string to be capitalized
Expression | Result |
---|---|
|
|
trim
Trims an input string (removes control characters (chars with code less than or equal to 32) from both ends).
#{trim($input)}
-
$input
- any string to be trimmed
Expression | Result |
---|---|
|
|
encodeToBase64
Encode the input string to Base64 format
#{encodeToBase64($input)}
-
$input
- any string to be encoded to Base64 format
Expression | Result |
---|---|
|
|
decodeFromBase64
Decodes the input string from Base64 format to the regular string
#{decodeFromBase64($input)}
-
$input
- Base64 string to decode
Expression | Result |
---|---|
|
|
toBase64Gzip
Compress the input string to GZip and encode compressed bytes to Base64 format
#{toBase64Gzip($input)}
-
$input
- any string to be compressed and encoded
Expression | Result |
---|---|
|
|
Resources
loadResource
Loads the resource found at the provided path and replaces the expression with the content of the resource.
#{loadResource($pathToResource)}
-
$pathToResource
- the path to the resource to load. It must be relative to the project, meaningsrc/main/resources
is left out of it. Therefore, if the file is located atmy-tests/src/main/resources/data/body.txt
, then it’s required to put only relative resource part:/data/body.txt
When I initialize the scenario variable `my-data` with value `#{loadResource(/data/body.txt)}`
loadBinaryResource
Loads the resource found at the provided path as bytes. Could be useful for the steps that accepting raw binary data.
#{loadBinaryResource($pathToResource)}
-
$pathToResource
- the path to the resource to load. It must be relative to the project, meaningsrc/main/resources
is left out of it. Therefore, if the file is located atmy-tests/src/main/resources/data/body.txt
, then it’s required to put only relative resource part:/data/body.txt
When I mock HTTP responses with request URL which CONTAINS `frames.html` using response code `200`, content `#{loadBinaryResource(page.html)}` and headers:
|name |value |
|Content-Type|text/html|
resourceToBase64
Finds the resource at the provided path and replaces the expression with the content of the resource in Base64 format.
#{resourceToBase64($pathToResource)}
-
$pathToResource
- the path to the resource to load. It must be relative to the project, meaningsrc/main/resources
is left out of it. Therefore, if the file is located atmy-tests/src/main/resources/data/body.txt
, then it’s required to put only relative resource part:/data/body.txt
When I initialize the scenario variable `my-data` with value `#{resourceToBase64(/data/body.txt)}`
Script evaluation
eval
Evaluates JEXL script and converts result to a string.
#{eval($script)}
-
$script
- valid JEXL script to be evaluated
-
Any Vividus variable is accessible in the JEXL script by its name
Scenario: Verify eval expression
Then `#{<expression>}` is = `<expected>`
Examples:
|expected |expression |
|null |eval(null) |
|28 |eval(16 + 2 * 6) |
|10 |eval(math:abs(-10)) |
|here |eval(stringUtils:substringAfterLast('namescpaces are %here', '%'))|
|108 |eval((16 + 2) * 6) |
|-6 |eval(100 / 5 - 16 * 2 + 6) |
|true |eval(`string\n1` == `string\n1`) |
|false |eval(`string\n1` == `string1`) |
|I Am FINE |eval(wordUtils:capitalize('i am FINE')) |
|i am fINE |eval(wordUtils:uncapitalize('I Am FINE')) |
|tHE DOG HAS A bone|eval(wordUtils:swapCase('The dog has a BONE')) |
|FRD |eval(wordUtils:initials('Fus Ro Dah')) |
evalGroovy
Evaluates groovy script and converts result to a string.
#{evalGroovy($script)}
-
$script
- valid Groovy script to be evaluated
|
When I initialize Scenario variable `listOfMaps` with values:
|key|
|2 |
|1 |
|3 |
Then `1-2-3` is = `#{evalGroovy(return listOfMaps.collect{it['key']}.sort().join('-'))}`