Manual

3.1+46.7
Test-run listeners

Once registered with the current run-context via rc.addTestRunListener, an implementation of the TestRunListener interface will get notified whenever test execution enters or exits a node and when a problem occurs. An illustrative example is provided in the test-suite TestRunListener.qft, located in the directory demo/runlistener in your QF-Test installation. Best deactivate the debugger before running the whole test-suite.

Note A variant of the TestRunListener interface called DaemonTestRunLister can be used to monitor a test-run remotely via the daemon API. It is described in subsection 47.2.5.

The run listener API consists of the following classes:

46.7.1
The TestRunListener interface

The interface de.qfs.apps.qftest.extensions.qftest.TestRunListener has to be implemented and registered with a run-context via rc.addTestRunListener().

Note To implement the interface you can also derive from the class de.qfs.apps.qftest.extensions.qftest.AbstractTestRunListener which provides empty implementations of all methods so you only need to implement those methods you are interested in.

 
 
void runStarted(TestRunEvent event)
Notify the listener that a test-run was started.
Parameters
eventThe event containing the details, irrelevant in this case.
 
void runStopped(TestRunEvent event)
Notify the listener that a test-run was stopped.
Parameters
eventThe event containing the details, irrelevant in this case.
 
void nodeEntered(TestRunEvent event)
Notify the listener that a node is being entered.
Parameters
eventThe event containing the details.
 
void nodeExited(TestRunEvent event)
Notify the listener that a node was just exited.
Parameters
eventThe event containing the details.
 
void problemOccurred(TestRunEvent event)
Notify the listener that a problem occurred.
Parameters
eventThe event containing the details.
 
 
46.7.2
The class TestRunEvent

The class de.qfs.apps.qftest.extensions.qftest.TestRunEvent holds information about the currently executed nodes and the current error state. It defines the following constants for execution states and error levels: STATE_NOT_IMPLEMENTED, STATE_SKIPPED, STATE_OK, STATE_WARNING, STATE_ERROR and STATE_EXCEPTION. The first two states apply only to 'Test-set' and 'Test-case' nodes.

In the runStopped method you can also check whether the test run has been interrupted or completed normally. Therefore the constants STATE_RUN_INTERRUPTED and STATE_RUN_TERMINATED are defined.

 
 
TestSuiteNode getNode()
Get the current node
Returns The current node or null for runStarted and runStopped.
 
TestSuiteNode[] getPath()
Get the whole tree path for the current node.
Returns The path for the current node as seen from the run-log, equivalent to the execution stack, or null for runStarted and runStopped. The last node in the array is the current node.
 
int getState()
Get the overall execution state for the current node.
Returns The overall propagating state for the current node, the highest error level of this node and its children, possibly limited by 'Maximum error level' attributes. Available only for nodeExited and problemOccurred.
 
int getLocalState()
Get the execution state for the current node.
Returns The local execution state for the current node, the highest error level of this node and its children regardless of whether this state propagates to the top. Available only for nodeExited and problemOccurred. For 'Test-set' and 'Test-case' nodes the local state can also be one of STATE_SKIPPED or STATE_NOT_IMPLEMENTED.
 
String getMessage()
Get the current error message.
Returns The message for the current warning, error or exception. Only available for problemOccurred.
 
int getExceptions()
Get the exception count for the exited node.
Returns The total exception count for the node just exited. Only available for nodeExited.
 
int getErrors()
Get the error count for the exited node.
Returns The total error count for the node just exited. Only available for nodeExited.
 
int getWarnings()
Get the warning count for the exited node.
Returns The total warning count for the node just exited. Only available for nodeExited.
 
JsonObject asJsonValue()
Serializes the event object as JsonObject. This can be used to simplify the interaction of TestRunListeners with Json-based tools like web services or databases. The API of the Json library embedded in QF-Test is documented in the file doc/javadoc/json.zip in your QF-Test installation
Returns The object as JsonObject.
 
 
46.7.3
The class TestSuiteNode

A de.qfs.apps.qftest.extensions.qftest.TestSuiteNode is a representation of a QF-Test node that is currently being executed, including information about the type of node, its name, comment, etc.

 
 
String getSuite()
Get the test-suite to which the node belongs.
ReturnsThe full path of the test-suite to which the node belongs.
 
String getType()
Get the type of the node.
Returns The type of node, the last part of the name of the class implementing the node's behavior.
 
String getName()
Get the name of the node.
Returns The name of the node or null if that type of node does not have a 'Name' attribute.
 
String getReportName()
Get the report name of the node.
Returns The expanded report name for 'Test-set' and 'Test-case' nodes. The normal name for other nodes or null if undefined.
 
String getTreeName()
Get the tree name of the node.
Returns The name of the node as displayed in the test-suite tree.
 
String getId()
Get the ID of the node.
ReturnsThe ID of the node.
 
String getComment()
Get the comment of the node.
ReturnsGet the expanded comment of the node.
 
String getComponentId()
Get the QF-Test ID of the component of the node, if available.
ReturnsGet the expanded QF-Test ID of the component of the node.
 
JsonObject asJsonValue()
Serializes the node as JsonObject.
Returns The object as JsonObject.