Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Jubula » User defined functions: external methods HowTo
User defined functions: external methods HowTo [message #1793282] Thu, 02 August 2018 23:02 Go to next message
Milos Hroudny is currently offline Milos HroudnyFriend
Messages: 17
Registered: June 2017
Junior Member
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:
//File Exists
public static String fileExists(String filePath)
{
int count= 0
File file = new File(filePath);
if (file.isFile())
{
count++;
}
return Integer.toString(count);
}
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.:
d:\Program Files\jubula_8.5.0.127\ite\externaljars\
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
VARIABLE_NAME: EM1_path
VALUE: =FILE_PATH
Configuration of the <ub_rfl_invokeExternalAndStore> would be
VARIABLE_NAME: ExternalMethodValue
FULLY_QUALIFIED_CLASS_NAME: com.my.util.ExternalFunctions
METHOD_NAME: fileExists
METHOD_SIGNATURE: java.lang.String
METHOD_ARGUMENTS: $EM1_path
METHOD_ARGUMENT_SEPARATOR: ','
TIMEOUT_IN_MS: 3000
To apply <FileExists> we configure the parameter of the reference to the module,e.g.:
FILE_PATH: 'd:\myfile1.txt'
Re: User defined functions: external methods HowTo [message #1793708 is a reply to message #1793282] Tue, 14 August 2018 12:05 Go to previous message
Marvin Mueller is currently offline Marvin MuellerFriend
Messages: 115
Registered: March 2012
Senior Member
Thanks for all the Howtos, they may really be helpful for some people!

best regards
Marvin
Previous Topic:Tree Table input text in specific cells?
Next Topic:User defined functions: extension functions 1 HowTo
Goto Forum:
  


Current Time: Wed Sep 26 04:29:28 GMT 2018

Powered by FUDForum. Page generated in 0.02370 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top