Logo QF-Test

Completely documented in two languages.
Manual = The QF-Test reference work

 

Free Trial  Download  Buy

Help is given in the software itself, too.

You can access the whole documentation directly from within QF-Test.

Uwe Klüh, Senior Sales Manager, QFS

Find the information you need in the whole documentation (Manual, Tutorial, Mailing list, Standard library) by using the online search above.

Uwe Klüh, Sr. Sales Manager, QFS

Manual

4.0.3+42.8
ResetListener

During test development you sometimes want to reset all QF-Test variables, as well as stopping all connected clients. By this step it is guaranteed, that a test execution does not fail due to side impacts coming from a previous one. This could happen if global variables get an incorrect value assigned or because the connected client may be in a wrong state.

For resetting all QF-Test variables and clients, you could utilize the menu action »Run«-»Reset everything«. This action could be utilized for further use-cases. It could happen, that too many variables were deleted or another typical situation could to reset global Jython or Groovy variables. Those variables cannot be reset by this menu action per default. In addition you might want to de-register a TestRunListener. In order to meet those requirements and to offer the capability to implement custom post conditions, the ResetListener interface has been introduced.

Each class object that implements the ResetListener Interface de.qfs.apps.qftest.extensions.qftest.ResetListener and was registered in QF-Test represents a ResetListener. To manage those ResetListener, the QF-Test runcontext provides the methods addResetListener, isResetListenerRegistered and removeResetListener.

The ResetListener Interface is composed of two methods:

 
 
beforeReset()
This method will be called, before all QF-Test variables and clients will get resetted. Implementing this method may also prevent certain clients from closing, when the »Run«-»Reset everything« function gets invoked.
Returns A java.util.Set<String> Object, that contains the name of all clients, that should not get closed/resetted.
 
afterReset()
This method will be called, once all QF-Test variables and clients got resetted.
 
 

The following example describes the implementation and registration of a ResetListener. The ResetListener prevent, that the QF-Test variable "client" gets deleted by the Reset function. It prevents the closing of the "client" SUT too.

from java.util import HashSet
from de.qfs.apps.qftest.extensions.qftest import ResetListener
from de.qfs.apps.qftest.shared.exceptions import UnboundVariableException

class L(ResetListener):
    def beforeReset(self):
        try:
            self.client = rc.lookup("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:
    resetListener
except:
    resetListener = L()
    rc.addResetListener(resetListener)
          
Example 42.47:  An example of the implementation of a ResetListener
Videos Downloads Documentation Buy Free Trial