2
What’s this about?
• QFSTestJUI is a capture/replay test driver for Java applications
• A capture/replay tool works exactly like a cassette-recorder: you first record, then you can play back as many times as you want
• This is useful for testing Java GUIs and for exercising systems whose only access is via a GUI
3
System Under Test
• A System Under Test (SUT) is an user application that runs from qftestJUI.
• JDK or JRE instrumentation is used to provide a way for qftestJUI to interact with SUT (Chapter 17 manual)
4
Node
Insertion Marker
Run Buttons Debug ButtonsRecord Buttons
Terminal Output Area
No
de
Att
ribu
tes
Children
qftestJUI GUI
Sequence Node
Test Node
6
Sequence and Test Nodes
• A Sequence node executes its child nodes one by one in the order they appear.
The concept behind a Sequence node is that its child nodes must be run in exactly that order and that each node depends on the outcome of the previous node to work correctly. A sequence of recorded events is a very good example for what constitutes a Sequence node.
• A Test node also executes its independent children one by one after having guaranteed for each of them similar conditions (Setup and Cleanup).
8
Various methods to start the SUT
• There are basically two ways to start a Java application as an SUT from qftestJUI.
• The first one is based on the standard java ... command line with its two variants for either starting a class or a jar file.
• The alternative is running a script or executable file which will then start the Java program.
• Indirect methods like launching the SUT through ant also fall into this category, as do Java WebStart and applets run in the Java plugin of a web browser.
12
Recording Components (2)
• All graphical items in a GUI are translated by qftestJUI in Windows and Components Nodes with an unique ID.
• Users can use the method setName to assign his/her own unique name(ID).
• Component recognition is done via an good, but not perfect, algorithm. The usage of setName makes it reliable over time (changes).
18
Implicitly Catch Exception• When an exception is thrown during the execution of one of the
Test’s normal child nodes, the Test is usually terminated prematurely.
• This may not be what you want, since no information is gained from the execution of the rest of the child nodes.
• If the Setup and Cleanup of the test are set up so you can guarantee the same initial conditions for each child node even in the case of an exception, you can set this attribute to make the Test catch the exception implicitly.
• That way, if an exception is caught from a normal child node, the exception is logged and the execution of that child node is stopped. Then the Test continues with the Cleanup as if nothing had happened.
• Exceptions thrown during the execution of either the Setup or the Cleanup cannot be caught that way and will always terminate the Test.
23
Variables• $(var) # Expands to the value
of some previously defined variable
• ${group:name} #Accesses external data from a resource bundle or property file
• $[expression] #Evaluates some mathematical expression
26
Procedures
Parameter passed color=red
Local Variable color=green is overridden with value “red”
Local Variable color=green
28
Includes others Suites
qftestJUI -batch -report.copyicons -report.depth 10 -report.html %b.html -systemcfg $HOME/qftestJUI.cfg -variable IP=$IP -variable HOST=$HOST -variable HOME=$HOME -libpath $HOME -runlog %b.qrz acscommandcenter.qft
33
Scripting
• qftestJUI can embed Jython scripts into its own test-suite. There are two Nodes for this: Server Script and SUT Script
• Server Scripts are run in a Jython interpreter embedded in qftestJUI
• SUT Scripts are run in a Jython interpreter embedded in the SUT
35
RC Variable
RC represent the run-context which encapsulates the current state of the execution of the test. It provides an interface for accessing qftestJUI’s variables, for calling qftestJUI Procedures and can be used to add messages to the run-log. To SUT scripts it also provides access to the actual Java components of the SUT’s GUI.
36
RC: Examples
rc.logMessage("This is a plain message")
rc.check(var == 0, "!Value of var is 0")# global variable set in the Sequence Node (x=25)
# lookup is used to access values as strings
global x
x = 2 * int(rc.lookup("x"))# log some values
rc.logMessage("x=" + `x`)
37
RC and SUT’s GUI Components
For SUT scripts RC provides the method getComponent(“componentID”) that retrieves the information of the NODE with ID componentID.
# get the text field
global field
field = rc.getComponent("value")
# fetch its value
rc.logMessage("The current value is " + field.getText())
38
RC and Procedures
RC Variable can also be used to call back into qftestJUI and execute Procedure Noderc.callProcedure(“Package.Procedure”,
{“Parameter”:”Value”, “Parameter”:”Value”,…})
39
Jython’s Modules
Jython’s Modules are like Python’s Modules.
# Modules myModuleimport stringdef loadTable(file, separator=’|’): data = [] fd = open(file, "r") line = fd.readline() while line: line = string.strip(line) if len(line) > 0: data.append(string.split(line,separator)) line = fd.readline() return data
import myModule# load the datadata = myModule.loadTable(rc.lookup("filename"))