3.12.6.2 Pre-defined functions

The following functions are available directly in Jubula :

Mathematical functions
The following functions give their results as decimal numbers, e.g. 1.0, 1.2 etc.

add
Adds 0 or more numbers to 0, e.g.: "?add(1,2)".
sub
Subtracts the second number from the first: "?sub(3,2). This function only accepts two numbers."
mult
Multiplies 0 or more numbers by 1 e.g.: "?mult(2,4)".
div
Divides the first number by the second: "?div(2,1)". This function only accepts two numbers.
trunc
Takes two arguments, the decimal to be truncated and the precision (as an integer) to truncate the decimal to. Use "0" to cut off the number to no decimal places (i.e. to receive a plain integer), and use "1" to cut off the decimal to one decimal place etc: "?trunc(2.396,0)" gives "2" and "?trunc(2.789,1) gives "2.7"".
round
Takes two arguments, the decimal to be rounded and the precision (as an integer) to round to. This function uses half-up rounding to round the number so that if the final decimal place after rounding is 5 or higher, the final number will be incremented by 1 e.g.: "?round(2.56,1)" gives "2.6". If the final number after rounding is 4 or less, there is no incrementation, eg. "?round(2.46,1)" gives "2.4".
\includegraphics[height=2cm]{danger} It is currently only possible to use numbers formatted with the decimal mark period or fullstop ("."). Thousands separators may not be used. For example, "1.5" is accepted, but "1,5" is not. "1000" can be entered but "1,000" cannot. Entering "1.000" is equivalent to entering "1".
\includegraphics[height=2cm]{lightbulb} Use single quotes around negative numbers, e.g. '-0.5'.

Date functions

now
Saves the current date in an internal format that can be used as a basis for the formatDate and modifyDate functions. This function takes no arguments: "?now()".
formatDate
Puts a date into a specific format. The date to be formatted is entered as the first argument, followed by the format string e.g. "?formatDate(?now(), dd-MM-yyyy)". The formats that can used here are the formats from the SimpleDateFormat class in Java.
parseDate
Reads a value that is a date and parses it into an internal format based on the format string given (i.e. how the date should be understood by Jubula ). The first argument is the date, and the second is the format string "?parseDate(2011.06.25,yyyy.MM.dd)". This function should be used when reading and working with dates shown in the AUT .
modifyDate
This function can add days (d), months (M), and years (y) to a given date. The date must first be parsed (i.e. using parseDate) so that the correct internal format is used. This function takes two arguments: the first is the date to modify, and the second is the modification to perform, e.g. "?modifyDate(?now(),1d)". Additions are entered as positive integers (but without a plus sign, e.g. 1d, 1M, 1y) and subtractions are entered as negative integers, e.g. -1d, -1M, -1y.

\includegraphics[height=2cm]{lightbulb} If you want to use the result of a date function as a part of your test data (i.e. to enter or check), then you will most likely need to use formatDate on any date modifications you have performed.


Copyright BREDEX GmbH 2012. Made available under the Eclipse Public License v1.0.