Status: New
Owner: ----
Labels: Type-Enhancement Priority-Medium
New issue 1208 by [email protected]: allow listeners to receive suite,
test case and keyword objects as arguments
http://code.google.com/p/robotframework/issues/detail?id=1208
I would like to see a listener mode that passes the actual objects to the
listeners rather than just a few attributes. For example, I would like to
be able to write a listener like this:
ROBOT_LISTENER_API_VERSION = 3
def start_suite(suite):
print "starting suite", suite.name
Likewise for test cases and keywords.
Implementation is pretty straight-forward. In robot/output/listeners.py a
new clause would be added for each method. For example:
def start_suite(self, suite):
for li in self._listeners:
if li.version == 1:
li.call_method(li.start_suite, suite.name, suite.doc)
elif li.version == 2:
attrs = self._get_start_attrs(suite, 'metadata')
attrs.update({'tests' : [t.name for t in suite.tests],
'suites': [s.name for s in suite.suites],
'totaltests': suite.get_test_count()})
li.call_method(li.start_suite, suite.name, attrs)
elif li.version == 3:
li.call_method(li.start_suite, suite)
This takes a big step forward toward being able to control a test run via
the listener interface. The next step would be to put methods on the
objects that control the state of the test run. For example, a start_suite
listener might do something like 'suite.fail("blah blah")' to cause the
suite to fail at the point the listener was called.
The modification of the objects is not the subject of this feature request;
that will come in a later feature request. This request is solely for the
ability for the listener interface to pass the objects to the listeners.