Reputation: 41
I want to send the test report of Robot Framework by email for example to the leader. Recently, I made a send email library to use in robotframework's Suite Teardown, but soon, I found that the test report was generated after executing the Suite Teardown, so can not obtain the report. I wonder is there a way to do something like that in robotframework after the suite is over?
Upvotes: 3
Views: 1360
Reputation: 6961
Although @Jan is correct that using the close event
of the listener will allow you to do this, the real question is if you should. In my mind this no longer has anything to do with Test Automation and more with orchestration. Functionality like this typically expands over time and then this will certainly be the wrong place to put it.
This is why I would recommend looking at Jenkins (or any other CI like TravisCI, Bamboo etc) which has this kind of emailing functionality out-of-the-box. It will be a better maintainable solution over time and more flexible for future functionality.
For Robot Framework there exists a specific plugin.
Upvotes: 4
Reputation: 1582
I would make your mentioned library a Robot Framework library listener as described here: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-libraries-as-listeners
As at the time the close
listeners method is called, the context with automatic variable ${REPORT_FILE}
is gone, you need to combine it e.g. with library constructor like this:
class YourLibrary(object):
ROBOT_LISTENER_API_VERSION = 2
def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self
self._path_to_report = BuiltIn().get_variable_value('${REPORT_FILE}')
def _close(self):
self.call_your_method_to_send_the_report(self._path_to_report)
Note: it shouldn't matter if you'll use listener version 2 or 3.
Upvotes: 1