390 likes | 523 Vues
qftestJUI. M. Pasquato European Southern Observatory Garching, 12 - Jan - 2006. What’s this about?. QFSTestJUI is a capture/replay test driver for Java applications
E N D
qftestJUI M. Pasquato European Southern Observatory Garching, 12 - Jan - 2006
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
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)
Record Buttons Run Buttons Debug Buttons qftestJUI GUI Node Insertion Marker Children Node Attributes Test Node Sequence Node Terminal Output Area
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).
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.
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).
Deterministic Try/Catch Attribute to be Set Base class for all exceptions: TestException
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.
Implicitly Catch Exception (2) Attribute to be Set Attribute to be Set
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
Variables: Priority (2) Low Priority Procedures Variables High Priority
Control Structures Nodes: Loop Fixed Value Parameter
Procedures Parameter passed color=red Local Variable color=green Local Variable color=green is overridden with value “red”
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
Modularization General Variable
Debugger Step-in Step-out Step-over Breakpoint
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
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.
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`)
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())
RC and Procedures RC Variable can also be used to call back into qftestJUI and execute Procedure Node rc.callProcedure(“Package.Procedure”, {“Parameter”:”Value”, “Parameter”:”Value”,…})
Jython’s Modules Jython’s Modules are like Python’s Modules. import myModule # load the data data = myModule.loadTable(rc.lookup("filename")) # Modules myModule import string def 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