You can find usage of the commands below in:
List of commands:
- BYTES
- CONCAT
- CURRENT_DATE
- CURRENT_DATE_TIME
- DATE_PARSE
- DATE_TIME_PARSE
- DIVIDE
- EMPTY_STRING
- ENV
- FILE
- FORMAT_DATE
- FORMAT_DATE_TIME
- LOWER_CASE
- MAP
- MINUS
- MULTIPLY
- NEXT_CALENDAR_DAY
- NIL
- NULL
- PLUS
- RANDOM_DATE
- RANDOM_DATE_TIME
- RANDOM_EMAIL
- RANDOM_NUMBER
- RANDOM_NUMBER_IN_RANGE
- RANDOM_STRING
- RESOURCE
- ROUND
- SUBSTR
- TEST_CONTEXT_COPY
- UNESCAPE
- UPPER_CASE
Provides byte array for string in SOAP or REST requests.
- param - string
- result - TestContext reference pointing to byte array
This command simply concatenates the arguments it is supplied with. It can concatenate two and more arguments and the arguments can be commands as well.
Examples:
{CONCAT:1:2:3:4:5} {CONCAT:12:{CONCAT:3:4:5}}
Both examples above produce the result
12345
Current date command returns text form of current date.
The CurrentDateCommand can be used in JBehave's tables in three ways:
{CURRENT_DATE}
without parameter, is evaluated to the current date{CURRENT_DATE:<number>}
with numeric parameter, is evaluated to the current date shifted about given number of days{CURRENT_DATE:<period>}
with period parameter, is evaluated to the current day shifted about given period of time, see {@link java.time.Period#parse}
Current datetime command returns text form of current datetime.
The CurrentDateTimeCommand can be used in JBehave's tables in three ways:
{CURRENT_DATE_TIME}
without parameter, is evaluated to the current datetime{CURRENT_DATE_TIME:<number>}
with numeric parameter, is evaluated to the current datetime shifted about given number of seconds{CURRENT_DATE_TIME:<period>}
with period parameter, is evaluated to the current datetime shifted about given period of time, see {@link java.time.Period#parse}
Command for parsing date. Command consumes two arguments:
- date in string format
- format.
Example:
{DATE_PARSE:05/20/2031:MM/dd/yyyy}
Command for parsing datetime. Command consumes two arguments:
- datetime in string format
- format.
Example:
{DATE_TIME_PARSE:10.15.30 05/20/2031:HH.mm.ss MM/dd/yyyy}
Command for dividing first parameter by others
Default rounding is to 10 decimal places, can be changed by property numeric.scale
Example:
{DIVIDE:10:5:4}
Result of the command:
0.5
This command produces empty string.
Examples:
{EMPTY_STRING} {EMPTY}
Returns the value of specified environment property.
Examples:
{ENV:PROPERTY_NAME}
Provides canonical path to file. Command consumes two parameters:
- the resource location, e.g. org/jbehavesupport/core/expression/FileCommandTest.class
- optional name of file
Example:
{FILE:image.png}
Format date to expected format. Command consumes two arguments:
- date in string format
- output format
Example:
{FORMAT_DATE:2031-05-20:MM/dd/yyyy}
Format datetime to expected format. Command consumes two arguments:
- datetime in string format
- output format
Example:
{FORMAT_DATE_TIME:2031-05-20T10\:30\:11:MM/dd/yyyy HH\:mm\:ss}
This command takes one parameter that gets converted to lower case.
Example:
{LOWER_CASE:FOO} {LC:Foo}
Both the examples above produce the result
foo
Maps the first argument according to the mapping supplied in the second argument. It can be used when the value passed in a SOAP message is shown in the UI differently. True might be displayed as Yes. Mapping must be supplied as a comma delimited list of comma delimited tuples in brackets [ ].
Example:
{MAP:0:[0,Zero],[1,One],[Unknown]}
Produces result
Zero
This command simply subtract parameters from first one
Example:
{MINUS:2:2:3}
Result of the command:
-3
This command simply multiply parameters
Example:
{MULTIPLY:2:2:3}
Result of the command:
12
Command consumes one parameter as day. If the day is higher or equal to day from TimeFacade
current month is used. If the day is lower than day from TimeFacade
we will reset day to 1 and set month to next month.
Example:
{NEXT_CALENDAR_DAY:2}
If today is
2018-03-10
the result will be2018-03-12
Dedicated to send nil=true in SOAP request for JAXBElement.
Example:
[$request] data for [$application]: | name | data | | Foo.validTo | {NIL} |
This command takes no parameters.
Example:
{NULL}
This command simply do the sum of parameters.
Example:
{PLUS:2:2:3}
Result of the command:
7
Generates random date in range 1970 - 2059 by default. Takes up to 2 optional parameters to specify start and/or end date in several formats:
- YYYY
- YYYY-M
- YYYY-M-D
Example:
{RANDOM_DATE} {RANDOM_DATE:1999} //Random date since 1999-1-1 till 2059-12-31 {RANDOM_DATE:2000-5} //Random date since 2000-5-1 till 2059-12-31 {RANDOM_DATE:2001-6-7} //Random date since 2001-6-7 till 2059-12-31 {RANDOM_DATE:2002:2003} //Random date since 2002-1-1 till 2003-1-1 {RANDOM_DATE:2002-4-5:2003-8-9} //Random date since 2002-4-5 till 2003-8-9
Result of the command:
LocalDate object
Generates random datetime in range 1970 - 2059 be default. Takes up to 2 optional parameters to specify start and/or end date see RANDOM_DATE. Time range is not implemented yet, please rise request if you see reasonable application for your test case.
Example:
{RANDOM_DATE_TIME}
Result of the command:
LocalDateTime object
Creates a valid random email according with fixed length.
Example:
{RANDOM_EMAIL}
Result of the command:
xslk@wkle.com
Generate random numeric string with specific length. Command consumes one parameter:
- length of random number.
Example:
{RANDOM_NUMBER:3}
Result of the command:
957
Generate random number in range.
Example:
{RANDOM_NUMBER_IN_RANGE:3:5}
Result of the command:
9576
Generate random string with specific length. Command consumes one parameter which specified random string length.
Example:
{RANDOM_STRING:2}
Result of the command:
aD
Provides byte array for sending files in SOAP or REST requests.
- param - string path to resource
- result - TestContext reference pointing to Resource
Example:
{RESOURCE:image.png}
Result of the command:
Resource object
This command round first parameter
Example:
{ROUND:2.1111:2}
Result of the command:
2.11
Returns a string that is a substring of the first parameter. The substring begins at the index specified by second parameter and extends to the character at index - 1 specified by the third parameter (or end of string if the optional third parameter is missing).
Example:
{SUBSTR:unhappy:2}
Result of the command:
happy
Get value from test context. Short hand CP
. Command consumes two parameters:
- key in test context
- optional - prefix which will be added to result
Example:
{CP:FIRST_NAME}
Result of the command will be data from test context.
Unescapes any java literals found in string, useful for sending special characters like whitespaces.
Example:
{UNESCAPE:\t} {UNESCAPE:FirstLine\nSecondLine}
Result of first command is tab. Second command will produce:
FirstLine SecondLine
This command takes one parameter that gets converted to upper case.
Examples:
{UPPER_CASE:foo} {UC:Foo}
Both the examples above produce the result
FOO