4.0.3+54.7 ResetListener
During test development you sometimes want to stop all connected clients and reset all dependencies as well as delete global QF-Test variables in order to establish a well defined starting point for the next test execution.
For that purpose QF-Test offers »Run«-»Reset everything« in its main menu. To accommodate their particular needs test developers can additionally implement a ResetListener which allows to
- keep (certain) clients alive
- restore global QF-Test variables
- perform custom operations, for example deleting global Jython variables
To manage ResetListeners the QF-Test runcontext
provides the methods addResetListener(),
isResetListenerRegistered() and removeResetListener().
The ResetListener interface itself has two methods:
|
|||||||||||||||||
The following example shows the implementation and registration of a ResetListener. It
restores the global QF-Test variable client and prevents from closing the
respective SUT.
from java.util import HashSet
from de.qfs.apps.qftest.extensions.qftest import ResetListener
from de.qfs.apps.qftest.shared.exceptions import UnboundVariableException
class RL(ResetListener):
def beforeReset(self):
try:
self.client = rc.getStr("client")
h = HashSet()
h.add(self.client)
return h
except UnboundVariableException:
self.client = None
def afterReset(self):
if self.client != None:
rc.setGlobal("client", self.client)
global resetListener
try:
rc.removeResetListener(resetListener)
except:
pass
resetListener = RL()
rc.addResetListener(resetListener)