|Static functions in Jubula - HowTo [message #1793227]
||Wed, 01 August 2018 19:54
| Milos Hroudny
Registered: June 2017
For many tests are standard tools contained in toolkits sufficient. Anyway it can be handy to use also other than standard pre-defined Jubula functions. We can simply call static functions from Java libraries. |
Since the version 8.2.2 Jubula provides the category of modules "Invoke Method" which includes both external method calls and AUT static function calls. We can consider all standard Java functions as AUT static functions. Modules for calling the AUT methods are available in the toolkit unbound_modules_concrete_[8.5], in the path Actions(basic)→InvokeMethod. For calling Java static functions that are available in Java we use <ub_rfl_invoke> and < ub_rfl_invokeAndStore> modules. From module names is there clear that one type of module we use for procedures and another one in case of functions.
If we are working with any Java technology, there is the java.lang package available. This package contains a number of static functions in different libraries. The easiest to use is the Math library.
Let's say that we want to use the static function "Abs". We can create a user defined module <AbsValue> that contains the <ub_rfl_invokeAndStore> module reference configured following way:
When applying <AbsValue> module, we configure only the parameter ARGUMENT, e.g. by the value '-555'.
Notice: The method signature (METHOD_SIGNATURE) parameter contains a comma-separated list of parameters. As parameters in the signature of the method must be used wrapper classes, e.g. java.lang.String, java.lang.Number and the like, eventhough the method actually works with simple data types. The actual parameters we write to the METHOD_ARGUMENTS field and we separate them by the character specified in the METHOD_ARGUMENT_SEPARATOR field. It does not necessarily have to be a comma, but it must be a character that does not appear in any of the arguments.
The name of the variable containing the result of the function is "FunctionResult" in this case. We use the variable in the following processing according to our need.
Powered by FUDForum
. Page generated in 0.02399 seconds