|User defined functions: external methods HowTo [message #1793282]
||Thu, 02 August 2018 23:02
| Milos Hroudny
Registered: June 2017
We have two options to define our own functions:|
1) external methods
2) extension functions using plug-ins.
Both options require programming in Java. A simpler, and therefore a preferred way for creating user defined functions, is the use of external methods where the only condition is the appropriate placement of jar files with static methods into Jubula. But simplicity is not for everybody. In the Jubula 8.5 we can use external methods only for Swing applications.
External methods are a new and simple way how to add functions that we need to perform tests, but they are not part of the standard Jubula feature package. An example follows:
We start with creating of a separate Java project, such as myExternalFunctions. We create the com.my.util package in the project and here the class ExternalFunctions. In this class, we define static methods that we will use in Jubula.
An example of the external method:
public static String fileExists(String filePath)
int count= 0
File file = new File(filePath);
We can simply verify the function by including it in the main method in our class. As soon as we have finished testing of the function, we comment the main method and then we generate the jar file, for example myExternalFunctions.jar. We copy this file to the externaljars Jubula's directory, e.g.:
If the directory does not exist, we need to create it first. Jubula uses this directory as an interface. If we include a jar file containing public static methods into the directory, Jubula accepts these methods as its own external methods. All public static methods that we defined in the ExternalFunctions class are now available for use in Jubula. Jubula provides in the unbound_modules_concrete_[8.5] toolkit on the Actions>Invoke Method path several test modules that can be used to recall external methods. We will chose <ub_rfl_invokeExternalAndStore> and <ub_rfl_invokeExternal> modules and wrap them into our user defined modules. Depending on whether the external method returns or does not return a value, we select the module.
We can create the module <FileExists> that contains references of two standard modules:
<ub_app_storeValue> and < ub_rfl_invokeExternalAndStore > .
Configuration of the <ub_app_storeValue> would be
Configuration of the <ub_rfl_invokeExternalAndStore> would be
To apply <FileExists> we configure the parameter of the reference to the module,e.g.:
Powered by FUDForum
. Page generated in 0.02370 seconds