Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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: 24
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 messageGo to next message
Marvin Mueller is currently offline Marvin MuellerFriend
Messages: 255
Registered: March 2012
Senior Member
Thanks for all the Howtos, they may really be helpful for some people!

best regards
Marvin
Re: User defined functions: external methods HowTo [message #1796913 is a reply to message #1793708] Mon, 22 October 2018 08:59 Go to previous messageGo to next message
Tomáš Richta is currently offline Tomáš RichtaFriend
Messages: 1
Registered: October 2018
Junior Member
Hello Miloš, I'd like to thank You for these HowTos also! I'm going through those right now, because we also develop a RCP application in our project and we desperately need to automate its testing! At this moment l'm stuck by the impossibility of mapping of org.eclipse.swt.widgets.Link widget, that has MouseListener on it with MouseAdapter overriding mouseUp method that calls some specific component method that e.g. enables the editing mode. I added the setData values according to the docs, but Jubula GUI does not see and does not add the component to the mappings list. Therefore I decided to call the editing method directly. Do You think it is possible? Have You ever solved any simmilar problem? Best regards, Tomáš R.
Re: User defined functions: external methods HowTo [message #1797767 is a reply to message #1796913] Tue, 06 November 2018 09:48 Go to previous message
Marvin Mueller is currently offline Marvin MuellerFriend
Messages: 255
Registered: March 2012
Senior Member
Writing an extension for not supported components can be easy, or can be complicated, it depends on how far you want to support the component. If you just want to support a component to be clickable there this is a easy task[1]. If you want to support a component in a more specific way(like having a own implementation of a List) you must write a extension[2]

best regards
Marvin Mueller
[1] https://help.eclipse.org/2018-09/topic/org.eclipse.jubula.client.ua.help/content/html/userManual/concepts/ch06s13.html
[2] https://help.eclipse.org/2018-09/topic/org.eclipse.jubula.client.ua.help/content/html/developerManual/toolkitExtension/ch03.html
https://help.eclipse.org/2018-09/topic/org.eclipse.jubula.client.ua.help/content/html/developerManual/toolkitExtension/ch03s04.html
https://help.eclipse.org/2018-09/topic/org.eclipse.jubula.client.ua.help/content/html/developerManual/extensionWizard/ch05.html
Previous Topic:Can't install jubula for committers using oomph
Next Topic:Test support for applications combining SWT/Swing
Goto Forum:
  


Current Time: Thu Apr 25 01:14:16 GMT 2024

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

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

Back to the top